Difference between revisions of "Simple gui program ( Swing )"
From MyWiki
(One intermediate revision by the same user not shown) | |||
Line 8: | Line 8: | ||
public static void main(String[] args) { | public static void main(String[] args) { | ||
SwingUtilities.invokeLater(new Runnable() { | SwingUtilities.invokeLater(new Runnable() { | ||
− | + | public void run() { | |
− | + | createAndShowGUI(); | |
− | + | } | |
} | } | ||
); | ); | ||
Line 17: | Line 17: | ||
private static void createAndShowGUI() { | private static void createAndShowGUI() { | ||
System.out.println("Created GUI on EDT? "+ | System.out.println("Created GUI on EDT? "+ | ||
− | + | SwingUtilities.isEventDispatchThread()); | |
JFrame f = new JFrame("Swing Paint Demo"); | JFrame f = new JFrame("Swing Paint Demo"); | ||
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
Latest revision as of 09:08, 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); } }