Difference between revisions of "Simple gui program ( Swing )"
From MyWiki
(Created page with "<source lang="java"> import javax.swing.SwingUtilities; import javax.swing.JFrame; public class SwingPaintDemo1 { public static void main(String[] args) { Sw...") |
|||
(5 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
import javax.swing.JFrame; | import javax.swing.JFrame; | ||
− | public class SwingPaintDemo1 { | + | public class SwingPaintDemo1 |
+ | { | ||
public static void main(String[] args) { | public static void main(String[] args) { | ||
− | + | SwingUtilities.invokeLater(new Runnable() { | |
− | + | public void run() { | |
− | + | createAndShowGUI(); | |
− | + | } | |
− | + | } | |
+ | ); | ||
} | } | ||
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> |
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); } }