I'm not used to Java and JFrame as I'm just starting to learn.
My question is that, I have error at the method actionPerformed
. The error given is at the e.getsource == b
I believe.
From what I understand, the button I created at the public static void main(String[] args)
doesn't passed the value of the button to the actionPerformed
.
I'm sorry if my question is not clear.
Here is my code
public static void main(String[] args){
JButton b = new JButton("Click here");
JFrame newWindow = new JFrame("Test");
newWindow.setVisible(true);
newWindow.setSize(250,250);
newWindow.setLayout(null);
newWindow.add(b);
b.addActionListener(this);
}
Here is another part of my code
public void actionPerformed(ActionEvent e)
{
if ( e.getSource() == b )
{
//do something
}
}