Skip to content

Instantly share code, notes, and snippets.

@mythosil
Created February 21, 2012 15:24
Show Gist options
  • Save mythosil/1877014 to your computer and use it in GitHub Desktop.
Save mythosil/1877014 to your computer and use it in GitHub Desktop.
Swing sample
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
class SwingTest {
public static void main(String args[]) {
JFrame window = new JFrame("title");
JButton button = new JButton("button");
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent ae) {
System.out.println("button clicked");
}
});
window.add(button);
window.setLocationRelativeTo(null);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setSize(160, 160);
window.setVisible(true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment