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.
}
You should read this Tutorial about writing Event Listeners.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With