javaswingjinternalframeglasspane

Show InternalFrame in front of Glasspane


I want an InternalFrame to be shown in front of a GlassPane. In my program the user should be able to click on FILE -> Settings and an InternalFrame should be displayed. Everything in the background should be covered with a GlassPane. Does somebody have an idea?

m21.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
        Settings settings = new Settings();

        //get the InternalFrame
        settings.getFrame().setBounds(100,100,getWidth()-200, getHeight()-200);
        settings.getFrame().toFront();

        setGlassPane(new Glass());
        getGlassPane().setVisible(true);

        //get the InternalFrame
        getLayeredPane().add(settings.getFrame(), BorderLayout.NORTH);
        getLayeredPane().moveToFront(settings.getFrame());

        repaint();
    }
});

GlassPane


Solution

  • The point of the glass pane is to be in front of everything else:

    glasspane

    However, you can set any component as glass pane. My suggestion would be that you push the content of your settings frame as glass pane.