简体   繁体   中英

jInternalFrame not brought to the front

I have a JDesktopPane which contains a number of JInternalFrames. The first time I press one button to visible jinternalframe1 and second button to visible jinternalframe2, it appear above the main window without problems. However, if I press one of the buttons to Reopen jinternalframe1 or jinternalframe2, they are not brought in front of the main window...

EDIT: actually, i can't do anything with jinternalframe on a button click...i can only click once on the button and then no operation can be perform on the jinternalframe through the button..why it doesn't work!!

this is the coding of button1...

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) 
{                                             
    jinternalframe1 frame1 = new jinternalframe1();

    try {

        if(Allow.flag == false) {

            desktopPane.add(frame1);
            frame1.setVisible(true);
            Allow.flag = true;

        } else if(Allow.flag == true) {

            frame1.setSelected(true);

        }
    } catch(PropertyVetoException e) {
        System.out.println(e);
    }
}

Allow.java

public class Allow {
    static boolean flag = false;
}

Every time you click on the button you create a new JInternalFrame object, but you only ever add the first internal frame that you create to the desktop pane.

Don't keep creating new internal frame objects. I would guess you should only create the internal frame if your "frame1" variable is null.

If you need more help then post a proper SSCCE that demonstrates the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM