Skip to content

Instantly share code, notes, and snippets.

@yostane
Created January 3, 2021 12:16
Show Gist options
  • Select an option

  • Save yostane/4f3e86ac2ba93fa83fa0097f43348a8e to your computer and use it in GitHub Desktop.

Select an option

Save yostane/4f3e86ac2ba93fa83fa0097f43348a8e to your computer and use it in GitHub Desktop.
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.WindowConstants;
public class SimpleGui {
private static void createAndShowGUI() {
// Create and set up the window.
JFrame frame = new JFrame("HelloWorldSwing");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
// Add the ubiquitous "Hello World" label.
JLabel label = new JLabel("Hello World");
frame.getContentPane().add(label);
// Display the window.
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(SimpleGui::createAndShowGUI);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment