Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Why there are two init methods?

807599Feb 4 2007 — edited Feb 4 2007
I copied this code from netbeans for a JApplet.. and it has two init methods
One is public void init() that calls another initComponents() method.

And the initComponents() method has all the components defined in it, and it is private.
I replaced private with public and changed initComponents to init, and then deleted all the init method, it worked that way.
But why there two methods when you can put every thing in single init() method?

The init() method has this code in it:
public void init() {
        try {
            java.awt.EventQueue.invokeAndWait(new Runnable() {
                public void run() {
                    initComponents();
                    
                }
            });
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 4 2007
Added on Feb 4 2007
4 comments
130 views