JFrame ink rotation when opening another window

I do not want my main JFrame to become darker when the focus is in another window. This is an example from the game Football Manager 2012. First, the main window is selected, and it looks as it should, and then when it loads, it becomes darker and can not be selected. I don’t want this to affect my own application, but I'm really not sure how, I don’t even know what to do with Google?

Im guessing his JWindow, which appears, and JFram becomes unselectable in the background. I plan to use it in the help window in my application, that is, JWindow right now.

enter image description hereenter image description here

+5
source share
2

, JRootPane. :

getRootPane().setGlassPane(new JComponent() {
    public void paintComponent(Graphics g) {
        g.setColor(new Color(0, 0, 0, 100));
        g.fillRect(0, 0, getWidth(), getHeight());
        super.paintComponent(g);
    }
});

, "",

getRootPane().getGlassPane().setVisible(true);

- 100, .


.. JFrame, . setVisible (false), .

.

Shadow frame

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class ShadowedFrame extends JFrame {

    ShadowedFrame() {
        super("Shadowed Frame");
        getRootPane().setGlassPane(new JComponent() {
            public void paintComponent(Graphics g) {
                g.setColor(new Color(0, 0, 0, 100));
                g.fillRect(0, 0, getWidth(), getHeight());
                super.paintComponent(g);
            }
        });
        JButton popDialog = new JButton("Block Frame");
        popDialog.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                getRootPane().getGlassPane().setVisible(true);
                JOptionPane.showMessageDialog(ShadowedFrame.this, "Shady!");
                getRootPane().getGlassPane().setVisible(false);
            }
        });
        setContentPane(popDialog);
        pack();
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setLocationByPlatform(true);
        setSize(350,180);
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                new ShadowedFrame().setVisible(true);
            }
        });
    }
}
+8

(, ..) JLayeredPane. JComponent, . paintComponent(Graphics) . ( ) customComponent.setVisible(false).

Update

, , .

, JWindow, JFrame

, JDialog. , /, , ( ).

+4

All Articles