设置Jframe始终不在顶部

时间:2013-12-26 12:02:43

标签: java swing jframe

我设计了一个JFrame,并使用GraphicsDevice将其设置为全屏模式,问题是JFrame现在总是在顶部,我看不到另一个窗口,即使我按 Alt + Tab 。如何在使用JFrame

时正确地使GraphicsDevice无法始终排在首位
public class MyResolution {

        public MyResolution() {
            GraphicsEnvironment env=GraphicsEnvironment.getLocalGraphicsEnvironment();
            GraphicsDevice device=env.getDefaultScreenDevice();
            GraphicsConfiguration gc=device.getDefaultConfiguration();
            JFrame frame=new JFrame();
            DisplayMode mode=new DisplayMode(1024, 768, 16,0);
            device.setFullScreenWindow(frame);
            frame.setSize(300,500);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            DisplayMode[] modes = device.getDisplayModes();
            for (int i = 0; i < modes.length; i++) {
                //System.out.println("Best display mode: "+mode+", Modes:-"+modes[i]);
                if (modes[i].getWidth() == mode.getWidth()
                        && modes[i].getHeight() == mode.getHeight()
                        && modes[i].getBitDepth() == mode.getBitDepth()) {
                    device.setDisplayMode(mode);            }
            }
            frame.enableInputMethods(false);    
            frame.setAlwaysOnTop(false);
        }

        public static void main(String[] args) {
                MyResolution mine=new MyResolution();       
        }
}

1 个答案:

答案 0 :(得分:0)

使用下一个JFrame frame.setAlwaysOnTop(false);

frame是您的JFrame

相关问题