public MultiplicationTable()
{
JLabel jl;
JTextField tf;
JButton btn[];
Container c;
JPanel p1, p2, p3;
int a;
String value;
super ("Multiplication Table");
c = getContentPane();
p3 = new JPanel (new FlowLayout());
btn = new JButton[1];
btn[0] = new JButton ("Show Times Table");
jl = new JLabel ("Enter a Number:");
tf = new JTextField(5);
p3 = new JPanel (new BorderLayout(5,5));
p3.add (jl, BorderLayout.NORTH);
p3.add (tf, BorderLayout.CENTER);
p3.add (btn[0], BorderLayout.SOUTH);
btn[0].addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
String Value;
Value = tf.getText();
if (Value == "1")
{
System.out.print ("asd");
}
}
}
);
}
I would like to make the action listener for the button as I enter "1" in the text field. I really need to work on these codes. I wish you could help. Thanks!