JFrame myframe = new JFrame("My Sample Frame");
JButton mybutton = new JButton("Okay");
Can someone explain to me these part.
mybutton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
//Assuming that the content here will do something.
}
Best Answer
What exactly do you not understand about the code?
The code adds an action listener to the button. The
actionPerformed
method of the action listener will be called when the button is clicked.Note that an anonymous inner class is used here.