Created
March 10, 2017 21:39
-
-
Save benjaminaaron/8e9cdfc1d236cde006ffd0c2c5626a89 to your computer and use it in GitHub Desktop.
Simple Swing
This file contains 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 javax.swing.*; | |
public class Main { | |
public static void main(String[] args) { | |
JFrame frame = new JFrame("Simple Swing"); | |
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); | |
JPanel panel = new JPanel(); | |
frame.getContentPane().add(panel); | |
JLabel label = new JLabel("Hello Swing World"); | |
panel.add(label); | |
JButton button = new JButton(new AbstractAction("click me") { | |
@Override | |
public void actionPerformed(ActionEvent e) { | |
JOptionPane.showMessageDialog(null, "This is a message :)", "message", JOptionPane.INFORMATION_MESSAGE); | |
} | |
}); | |
panel.add(button); | |
frame.pack(); | |
frame.setVisible(true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment