Last active
August 29, 2015 14:22
-
-
Save janbiasi/b08759f07488356fe7e5 to your computer and use it in GitHub Desktop.
Simple eventhandling for frames and so on in java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.event.ActionEvent; | |
import java.awt.event.ActionListener; | |
class MyFrame extends JFrame { | |
private JFrame reference = this; | |
JButton myButton = new JButton(); | |
myButton.setText("Exit Applcation ..."); | |
/* Add listener for the button to close */ | |
myButton.addActionListener(new ActionListener() { | |
@Override | |
public void actionPerformed(ActionEvent ev) { | |
reference.dispose(); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment