Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/351.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 将Jframe设置为不始终位于顶部_Java_Swing_Jframe - Fatal编程技术网

Java 将Jframe设置为不始终位于顶部

Java 将Jframe设置为不始终位于顶部,java,swing,jframe,Java,Swing,Jframe,我设计了一个JFrame,并使用GraphicsDevice将其设置为全屏模式,问题是JFrame现在总是在顶部,即使按下Alt+Tab键,我也看不到其他窗口。如何正确地使JFrame在使用图形设备时不总是位于顶部 public class MyResolution { public MyResolution() { GraphicsEnvironment env=GraphicsEnvironment.getLocalGraphicsEnvironme

我设计了一个
JFrame
,并使用
GraphicsDevice
将其设置为全屏模式,问题是
JFrame
现在总是在顶部,即使按下Alt+Tab键,我也看不到其他窗口。如何正确地使
JFrame
在使用
图形设备时不总是位于顶部

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();       
        }
}
公共类MyResolution{
公开决议(){

GraphicsEnvironment env=GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice=env.getDefaultScreenDevice(); GraphicsConfiguration gc=device.getDefaultConfiguration(); JFrame=新JFrame(); 显示模式=新的显示模式(1024768,16,0); 设备。设置完整屏幕窗口(框架); 框架。设置尺寸(300500); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); DisplayMode[]modes=device.getDisplayModes(); 对于(int i=0;i
对您的
JFrame使用next


frame
是您的
JFrame

谢谢,但我尝试了这种方法,但由于我使用了图形设备,因此无法正常工作编辑您的问题。toFront,alwayson。。。。是为JDialog工作的方法,基于Windows操作系统声明属性的一堆愚蠢错误,不适用于JFrame的奇迹,历史问题(Win2000/NT???)GraphicsEnvironment env=GraphicsEnvironment.getLocalGraphicsEnvironment();GraphicsDevice=env.getDefaultScreenDevice();GraphicsConfiguration gc=device.getDefaultConfiguration();JFrame=新JFrame(gc);显示模式=新的显示模式(1024768,16,0);设备。设置完整屏幕窗口(框架);框架。设置尺寸(300500);DisplayMode[]modes=device.getDisplayModes();