Last active
December 14, 2015 16:58
-
-
Save kappa7194/5118400 to your computer and use it in GitHub Desktop.
My first Java GUI application.
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
package it.penpen.java.myproject; | |
import java.awt.FlowLayout; | |
import javax.swing.JButton; | |
import javax.swing.JFrame; | |
import javax.swing.JLabel; | |
import javax.swing.SwingUtilities; | |
public class MyClass implements Runnable { | |
public static void main(String[] args) { | |
FlowLayout layout = new FlowLayout(); | |
JLabel label = new JLabel("Hello, world."); | |
JButton button = new JButton("Click me."); | |
JFrame frame = new JFrame("Hello, world."); | |
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
frame.setLayout(layout); | |
frame.add(label); | |
frame.add(button); | |
frame.pack(); | |
frame.setVisible(true); | |
} | |
@Override | |
public void run() { | |
MyClass my = new MyClass(); | |
SwingUtilities.invokeLater(my); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment