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();