1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
| package passwd;
import java.awt.*; import java.awt.event.*; import javax.swing.*; import com.borland.jbcl.layout.*;
public class Frames extends JFrame { JPanel contentPane; XYLayout xYLayout1 = new XYLayout(); Panel panel1 = new Panel(); Panel panel2 = new Panel(); Panel panel3 = new Panel(); Panel panel4 = new Panel(); TextField textField1 = new TextField(); CheckboxGroup checkboxGroup1 = new CheckboxGroup(); Checkbox checkbox1 = new Checkbox(); Checkbox checkbox2 = new Checkbox(); Label label1 = new Label(); TextField textField2 = new TextField(); Label label2 = new Label(); TextField textField3 = new TextField(); Button button1 = new Button();
public Frames() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } private void jbInit() throws Exception { contentPane = (JPanel) this.getContentPane(); contentPane.setLayout(xYLayout1); this.setSize(new Dimension(400, 300)); this.setTitle("Frame Title"); textField1.setText(" "); checkbox1.setCheckboxGroup(checkboxGroup1); checkbox1.setLabel("high"); checkbox1.setState(true); checkbox2.setCheckboxGroup(checkboxGroup1); checkbox2.setLabel("low"); label1.setText("user"); textField2.setEchoChar('*'); textField2.setText(" "); label2.setText("passwd"); textField3.setText(" "); button1.setLabel("Check"); button1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { button1_actionPerformed(e); } }); panel1.add(checkbox1, null); panel1.add(checkbox2, null); contentPane.add(panel2, new XYConstraints(116, 62, 209, 23)); panel2.add(label1, null); panel2.add(textField1, null); contentPane.add(panel3, new XYConstraints(108, 101, 227, -1)); panel3.add(label2, null); panel3.add(textField2, null); contentPane.add(panel4, new XYConstraints(248, 194, 88, 33)); panel4.add(button1, null); contentPane.add(textField3, new XYConstraints(41, 201, -1, -1)); contentPane.add(panel1, new XYConstraints(14, 52, 64, 89)); } protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } }
void button1_actionPerformed(ActionEvent e) { String s1,s2; s1=String.valueOf(textField1.getText()); s2=String.valueOf(textField2.getText()); if(checkbox1.getState()){ if((s1 == "smart") && (s2 == "323232")) textField3.setText ("You input correctly"); else textField3.setText ("You input not correctly"); } else { if((s1 == "tom") && (s2 == "323232")) textField3.setText ("You input correctly"); else textField3.setText ("You input not correctly"); } } }
|