In button, u have two option, either :
- ActionListener, Or
- MouseListener
Action Listener
- only have actionPerformed(java.awt.ActionEvent e) function, will perform the action when the button is pressed and released
Mouse Listener
It have five function,
- mouseExited(java.awt.MouseEvent e) : will invoke when the mouse is exited the button
- mouseEntered(java.awt.MouseEvent e) : will invoke when the mouse is entered the button
- mouseReleased(java.awt.MouseEvent e) : will invoke when the mouse is released the button
- mousePressed(java.awt.MouseEvent e) : will invoke when the mouse is pressed the button
- mouseClicked(java.awt.MouseEvent e) : will invoke when the mouse is pressed and released the button
Okay, enough for the introduction, here the sample code for the button listener :
MainPanel.java
MainFrame.java
Sample Running :
you can test it by your self..
i hope you like this souce code...
and please give some comment....
Created By : Z-man, 2014
No comments:
Post a Comment