Ooh … Begitu! I see, I see …

Icon

Setelah kelayapan di internet, cari-cari info dari sana-sini dan bongkar pasang tips (terutama programming), akhirnya baru sadar … ternyata begitu caranya … [all about tricks and tips I have found during my work as programmer.]

setIcon(false); darn it …

a week, I’ve been coding uselessly, trying to redisplay my singleton JInternalFrame after it was minimized. I tried to add the setBounds(…) and toFront() but it didn’t appear from its minimized condition.

a week of coding and recoding and searching and searching, only to find that I only need to add this one:

try {
    singletonIF.setIcon(false);
} catch (PropertyVetoException ex) {
    ex.printStackTrace();
}

in order to release it from its minimized state.

and here is the code I needed to call the JInternalFrame as a singleton.

public static ifmGudang callTheInternalFrame(
        Container parent) {
    /*
     * Make sure it will have a parent 
     * to contain it.
     * if the parent is null, 
     * set frMain (the main form class) 
     * as it's parents.
     */
    if (parent == null) {
        /* 
         * this is my own static method 
         * to pass frMain's ContentPane
         * as this singleton's parent.
         */
        parent = frMain.setAsParent();
    }

    /*
     * make sure that the new instance 
     * will be created ONLY IF the singleton is null.
     */
    if (singletonIF == null) {
        singletonIF = new ifmGudang();
        parent.add(singletonIF, 
            javax.swing.JLayeredPane.DEFAULT_LAYER);
    } else {
        /*
         * needs to set Iconified false 
         * to release its minimized state.
         * found it that this one is needed 
         * to be applied before I add the 
         * setBounds(...)
         */
        try {
            singletonIF.setIcon(false);
        } catch (PropertyVetoException ex) {
            ex.printStackTrace();
        }
        singletonIF.toFront();
    }

    /*
     * make sure the singleton bounds 
     * with its parents.
     */
    singletonIF.setBounds(0, 0, 
        singletonIF.getParent().getWidth(),
        singletonIF.getParent().getHeight());
    singletonIF.show();
    return singletonIF;
}

hhh … it was only setIcon(false); thingy … darn it. the documentation reading was not as easy as I thought.

Advertisements

Filed under: Java programming, programming

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Archives

%d bloggers like this: