Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Greetings!

I fell upon this piece of code in the Oracle docs:

Java
public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI(); 
            }
        });


Until now, instead of
Java
createAndShowGUI
I was instructed to use
new
plus the name of the class. To build the GUI I would use a typical constructor.

But in the above example, the GUI is being built within a method which is called afterwards from the
Java
run()
method.

So is there any diference? (The full code from the docs can be found in http://docs.oracle.com/javase/tutorial/uiswing/painting/step2.html[^])
Posted
Comments
Sergey Alexandrovich Kryukov 24-Dec-14 17:37pm    
Difference?! Not clear. Instructed? By who, why? What is that supposed to mean? Then ask the one who "instructed" you.
The Oracle sample is clear, if you doesn't understand something, you could ask about it.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900