Difference between revisions of "Simple gui program ( Swing )"
From MyWiki
Line 16: | Line 16: | ||
private static void createAndShowGUI() { | private static void createAndShowGUI() { | ||
− | + | System.out.println("Created GUI on EDT? "+ | |
− | + | SwingUtilities.isEventDispatchThread()); | |
− | + | JFrame f = new JFrame("Swing Paint Demo"); | |
− | + | f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
− | + | f.setSize(250,250); | |
− | + | f.setVisible(true); | |
− | + | } | |
} | } | ||
</source> | </source> |
Revision as of 08:57, 6 July 2015
import javax.swing.SwingUtilities; import javax.swing.JFrame; public class SwingPaintDemo1 { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } } ); } private static void createAndShowGUI() { System.out.println("Created GUI on EDT? "+ SwingUtilities.isEventDispatchThread()); JFrame f = new JFrame("Swing Paint Demo"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(250,250); f.setVisible(true); } }