Included below are some examples of hand-coded JAVA applications created.
** JAVA LOGIN APPLET VIEW APPLET |
import java.awt.*; import java.applet.*; import java.net.*; import java.io.*; import java.awt.TextComponent; // import symantec.itools.awt.BaseTabbedPanel; public class Submit extends Applet { // StatusCanvas status = new StatusCanvas(); setBackground(new Color(16777215)); // public Component[] compo; void GoForIt(String s) { if (s.equals("password")) URL url; String pVal = password.getText(); // String url = "tests/"+pVal+".shtml"; String url = pVal+".html"; try { getAppletContext().showDocument(new URL(getDocumentBase(),url)); // { getAppletContext().showDocument( //new URL(getDocumentBase(),url), "_blank"); }catch(Exception e) { System.out.println("Password Invalidn Please Try Again."); // System.out.println("Unable to load URL:"); } } void button1_Clicked(Event event) { GoForIt(password.getText()); } void textField1_EnterHit(Event event) { GoForIt(password.getText()); button1.requestFocus(); // showStatus("logging in as "+password.getText()+ // " ... Please Wait..."); } public void init() { super.init(); // INIT_CONTROLS setLayout(null); setSize(120,24); button1 = new java.awt.Button(); button1.setLabel("Enter"); button1.setBounds(120,0,65,24); add(button1); password = new java.awt.TextField(); password.setEchoChar('*'); password.setBounds(0,0,120,24); add(password); } public boolean handleEvent(Event event) { if (event.target == password u0026amp;u0026amp; event.id == Event.ACTION_EVENT) { getAppletContext().showStatus( "logging in as "+password.getText()+" ... Please Wait..."); textField1_EnterHit(event); return true; } if (event.target == button1 u0026amp;u0026amp; event.id == Event.ACTION_EVENT) { getAppletContext().showStatus( "logging in as "+password.getText()+" ... Please Wait..."); button1_Clicked(event); return true; } if ((event.target == (button1) || (password)) u0026amp;u0026amp; (event.id == (Event.MOUSE_ENTER))) { getAppletContext().showStatus( "Enter Password and Select Enter."); return true; /* if (event.target == button1 u0026amp;u0026amp; event.id == Event.MOUSE_ENTER || event.target == password u0026amp;u0026amp; event.id == Event.MOUSE_ENTER) { getAppletContext().showStatus( "Enter Password and Select Enter."); return true; */ /* }else if(event.id==Event.KEY_PRESS u0026amp;u0026amp; event.key == 't') { for(int i=0;i<compo.length;i++) { if(event.target==compo[i]) { do { i=(i+(event.shiftDown() ? compo.length-1 : 1))%compo.length; } while (!compo[i].isEnabled()); compo[i].requestFocus(); return true; } } return false;*/ } return super.handleEvent(event); } //to move from one TextField to another using tabkey /* public boolean handleEvent(Event e) { if(e.id==Event.KEY_PRESS u0026amp;u0026amp; e.key == 't') { for(int i=0;i<compo.length;i++) { if(e.target==compo[i]) { do { i=(i+(e.shiftDown() ? compo.length-1 : 1))%compo.length; } while (!compo[i].isEnabled()); compo[i].requestFocus(); // if(compo[i] instanceof TextComponent) (( // TextComponent)compo[i]).selectAll(); return true; } } return false; } } */ /* public boolean mouseEnter(Event evt, int x, int y) { // TODO: Place applet mouseDown code here return true; } */ // DECLARE_CONTROLS java.awt.Button button1; java.awt.TextField password; } /* StatusCanvas defines the status bar in the frame */ /* class StatusCanvas extends Canvas { String strStatusText = ""; int loginStatus; StatusCanvas() { loginStatus = 0; } public void paint(Graphics g) { int w = size().width; int h = size().height; g.setColor(new Color(255,255,255)); g.fillRect(0,5,w,h); g.setColor(new Color(0,0,0)); g.setFont(new Font("Helvetica", Font.PLAIN, 10)); g.drawString(strStatusText,3,15); } */ /* method to set the status string */ /* public void setText(String strtxt) { strStatusText=strtxt; repaint(); } public Dimension minimumSize() { return new Dimension(225,20); } public Dimension preferredSize() { return minimumSize(); } } */ |
** JAVA / LDAP (NETSCAPE DIRECTORY SRVR) USER DATA RETRIEVAL |
import netscape.ldap.*; import netscape.ldap.util.*; import netscape.ldap.controls.*; import java.io.*; import java.util.*;public class sort { public static void main(String args[]) LDAPConnection ld = null; try String attrs [] = {“cn”,”sn”,”givenname”,”uid”}; /* Create sort keys that specify the sort order. */ /* Create a server control using that sort key. */ res = ld.search( base, scope, filter, attrs, false,cons); LDAPEntry findEntry = null; LDAPAttributeSet attributeSet = findEntry.getAttributeSet(); for (int i=0;i<attributeSet.size();i++) Enumeration enumVals = attribute.getStringValues(); catch(LDAPException e) try{ |