Methods Summary |
---|
public void | actionPerformed(java.awt.event.ActionEvent ae)
if(ae.getSource( ) == but1)
{
code = code + "1";
tf.setText(code);
}
if(ae.getSource( ) == but2)
{
code = code + "2";
tf.setText(code);
}
if(ae.getSource( ) == but3)
{
code = code + "3";
tf.setText(code);
}
if(ae.getSource( ) == but4)
{
code = code + "4";
tf.setText(code);
}
if(ae.getSource( ) == okBut)
{
code = tf.getText( );
if ((code.equals(defaultCode))||
(code.equals(userCode))||
(controlFlag == true))
{
if (rBut1.getState( ) == true)
{
userCode = code;
code = "";
waitaBit( );
tf.setText("New Code");
rBut3.setState(true);//switches off rBut1
waitaBit( );
disableController( );
tf.setText("");
}
else
{
enableController( );
}
if (rBut2.getState( ) == true)
{
}
}
}
|
public void | controlPanel()
displayP3 = new Panel( );
bGrp = new CheckboxGroup( );
rBut1 = new Checkbox("Change code", false, bGrp);
rBut2 = new Checkbox("Disable alarm", false, bGrp);
rBut3 = new Checkbox("Dummy", false, bGrp);
rBut1.addItemListener(this);
rBut2.addItemListener(this);
displayP3.add(rBut1);
displayP3.add(rBut2);
|
public void | disableController()
displayP3.setVisible(false);
validate( );
controlFlag = false;
|
public void | enableController()
add (displayP3,BorderLayout.SOUTH);
displayP3.setVisible(true);
validate( );
controlFlag = true;
|
public void | itemStateChanged(java.awt.event.ItemEvent ie)
if (ie.getSource( ) == rBut1)
{
tf.setText("");
code = "";
}
|
public void | midPanel()
displayP2 = new Panel( );
displayP2.setLayout(new FlowLayout( ));
displayP2.setFont(new Font("SansSerif",
Font.PLAIN,20));
but1 = new Button("1");
but2 = new Button("2");
but3 = new Button("3");
but4 = new Button("4");
but1.addActionListener(this);
but2.addActionListener(this);
but3.addActionListener(this);
but4.addActionListener(this);
displayP2.add(but1);
displayP2.add(but2);
displayP2.add(but3);
displayP2.add(but4);
|
public void | topPanel()
displayP = new Panel( );
labEC = new Label("Enter Code: ");
displayP.add(labEC);
tf = new TextField(7);
displayP.add(tf);
okBut = new Button("OK");
okBut.addActionListener(this);
displayP.add(okBut);
|
public void | waitaBit()
long timeInMis = System.currentTimeMillis( );
long t = 0;
do
{
t = t + 1;
} while (System.currentTimeMillis( ) < timeInMis
+ 1000);
|