Code 2

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

import java.awt.*; import java.sql.*; import java.awt.event.*; import java.util.*; import javax.swing.

*;

public class Form112 extends Frame implements ActionListener,WindowListener

Connection con; String str=""; int a[]=new int[100]; int[] pv1=new int[50]; int i=0,j=0;

Random rnumber=new Random();

TextField tx1=new TextField(20); /* TextField tx2=new TextField(20);*/ TextField tx3=new TextField(20);

Button login_button=new Button("Login"); Button reset_button=new Button("Reset");

Label lb1=new Label("User Name ");

/* Label lb2=new Label("Enter Password (Using Above Figure) ");*/

Label lb3=new Label("Enter position values in your password figure");

/* Button b1=new Button(Integer.toString(rnumber.nextInt(99)+1)); Button b2=new Button(Integer.toString(rnumber.nextInt(99)+1)); Button b3=new Button(Integer.toString(rnumber.nextInt(99)+1)); Button b4=new Button(Integer.toString(rnumber.nextInt(99)+1)); Button b5=new Button(Integer.toString(rnumber.nextInt(99)+1)); Button b6=new Button(Integer.toString(rnumber.nextInt(99)+1)); Button b7=new Button(Integer.toString(rnumber.nextInt(99)+1)); Button b8=new Button(Integer.toString(rnumber.nextInt(99)+1)); Button b9=new Button(Integer.toString(rnumber.nextInt(99)+1)); Button b10=new Button(Integer.toString(rnumber.nextInt(99)+1)); Button b11=new Button(Integer.toString(rnumber.nextInt(99)+1)); Button b12=new Button(Integer.toString(rnumber.nextInt(99)+1)); Button b13=new Button(Integer.toString(rnumber.nextInt(99)+1)); Button b14=new Button(Integer.toString(rnumber.nextInt(99)+1)); Button b15=new Button(Integer.toString(rnumber.nextInt(99)+1)); Button b16=new Button(Integer.toString(rnumber.nextInt(99)+1)); */

Button ba=new Button("A");

Button bb=new Button("B"); Button bc=new Button("C"); Button bd=new Button("D"); Button be=new Button("E"); Button bf=new Button("F"); Button bg=new Button("G"); Button bh=new Button("H"); Button bi=new Button("I"); Button bj=new Button("J"); Button bk=new Button("K"); Button bl=new Button("L"); Button bm=new Button("M"); Button bn=new Button("N"); Button bo=new Button("O"); Button bp=new Button("P");

public Form112() {

// tx2.setEchoChar('*'); tx3.setEchoChar('*');

setLayout(new FlowLayout(FlowLayout.CENTER));

Panel p1=new Panel(); Panel p2=new Panel(); Panel p3=new Panel(); Panel p4=new Panel(); Panel p5=new Panel(); Panel p6=new Panel();

p1.setLayout(new GridLayout(4,4,1,1)); p4.setLayout(new GridLayout(4,4,1,1)); p5.setLayout(new GridLayout(4,4,1,1)); p6.setLayout(new GridLayout(4,4,1,1)); p2.setLayout(new FlowLayout(FlowLayout.CENTER)); p3.setLayout(new GridLayout(1,2,15,5));

/*------------------------------------------------b1.addActionListener(this); b2.addActionListener(this); b3.addActionListener(this); b4.addActionListener(this); b5.addActionListener(this); b6.addActionListener(this);

b7.addActionListener(this); b8.addActionListener(this); b9.addActionListener(this); b10.addActionListener(this); b11.addActionListener(this); b12.addActionListener(this); b13.addActionListener(this); b14.addActionListener(this); b15.addActionListener(this); b16.addActionListener(this);

ba.addActionListener(this); bb.addActionListener(this); bc.addActionListener(this); bd.addActionListener(this); be.addActionListener(this); bf.addActionListener(this); bg.addActionListener(this); bh.addActionListener(this); bi.addActionListener(this); bj.addActionListener(this); bk.addActionListener(this); bl.addActionListener(this); bm.addActionListener(this); bn.addActionListener(this);

bo.addActionListener(this); bp.addActionListener(this);

-------------------------------------------------------*/ login_button.addActionListener(this); reset_button.addActionListener(this);

addWindowListener(this);

p2.add(lb1); p2.add(tx1);

p5.add(lb3); p5.add(tx3);

p6.add(ba); p6.add(bb); p6.add(bc); p6.add(bd); p6.add(be); p6.add(bf); p6.add(bg); p6.add(bh); p6.add(bi);

p6.add(bj); p6.add(bk); p6.add(bl); p6.add(bm); p6.add(bn); p6.add(bo); p6.add(bp);

/*

p4.add(lb2); p4.add(tx2); */

/*

p1.add(b1); p1.add(b2); p1.add(b3); p1.add(b4); p1.add(b5); p1.add(b6); p1.add(b7); p1.add(b8); p1.add(b9); p1.add(b10); p1.add(b11); p1.add(b12); p1.add(b13); p1.add(b14);

p1.add(b15); p1.add(b16); */

p3.add(login_button); p3.add(reset_button);

add(p2); add(p6); add(p5); add(p1); add(p4); add(p3);

//---------DATABASE Connection ---------------------------------------------------------

try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

con=DriverManager.getConnection("jdbc:odbc:krishna2");

catch(Exception e) { System.out.println(e); }

//--------------------------------------------------------------------------------------

/*----------------------Event Handling--------------*/

public void actionPerformed(ActionEvent ae)

{ String tname=tx1.getText();

String pos_value=tx3.getText(); String[] pv=pos_value.split("");

int j=0;

System.out.println("\npv values"); System.out.println("no.of values = "+pv.length); for(int i=1;i<pv.length;i++) System.out.println(" "+pv[i]+" ");

for(int i=1;i<pv.length;i++) { if(pv[i].equals("A"))

pv1[i]=11;

else if(pv[i].equals("B"))

pv1[i]=12;

else if(pv[i].equals("C"))

pv1[i]=13;

else if(pv[i].equals("D"))

pv1[i]=14;

else if(pv[i].equals("E"))

pv1[i]=21;

else if(pv[i].equals("F"))

pv1[i]=22;

else if(pv[i].equals("G"))

pv1[i]=23;

else if

You might also like