In the program code given below, the Frame contains three buttons named - "Bonjour", "Good Day", "Aurevoir". The purpose of these three buttons need to be preserved within a command associated with the button. That is a different action takes place on the click of each button.
You need to run this program outside the browser because this is an application. Moreover, if you don't to check that which button was selected then in that case you need to associate a different ActionListener to each button rather than associating one to all.
The following program demonstrates the event generated by each button.
|
Output of the program:
| C:\newprgrm>javac ButtonPressDemo.java C:\newprgrm>java ButtonPressDemo Good Morning clicked Good Day clicked C:\newprgrm> |

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Button Pressing Example View All Comments
Post your Comment