Java 图形设备-can';不能从全屏返回
我目前正试图在Linux上运行Java,制作一个全屏窗口。问题是,我实际上可以使JFrame全屏显示,但如果该帧设置为未装饰,则无法再次返回到原始窗口。如果窗户装饰好了,我可以恢复到原来的尺寸Java 图形设备-can';不能从全屏返回,java,graphics,jframe,fullscreen,Java,Graphics,Jframe,Fullscreen,我目前正试图在Linux上运行Java,制作一个全屏窗口。问题是,我实际上可以使JFrame全屏显示,但如果该帧设置为未装饰,则无法再次返回到原始窗口。如果窗户装饰好了,我可以恢复到原来的尺寸 GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gs = ge.getDefaultScreenDevice(); ... f.setUnd
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gs = ge.getDefaultScreenDevice();
...
f.setUndecorated(true);//If set Window can't return to original size
gs.setFullScreenWindow(f);
gs.setFullScreenWindow(null);//Doesn't work!
你知道如何解决这个问题吗?我不认为你能可靠地将未装饰的全屏画面改回窗口模式。我建议创建两个
JFrame
s,一个全屏,另一个窗口。当您想返回到窗口模式时,将内容窗格添加到窗口框架中(这会自动将其从全屏框架中删除),例如
这是一个好主意,但有一个小问题。我正在使用VLCJ,返回窗口帧会使视频变黑!没有任何图像。@mundu,我在尝试制作
JDialog
全屏时看到过这种情况,但使用JFrame
对我来说总是可以的。我目前正在使用JFrame和画布来绘制视频帧。它们与以下命令同步<代码>mediaPlayer=factory.newEmbeddedMediaPlayer();mediaPlayer.setVideoSurface(factory.newVideoSurface(canvas))代码>
windowedFrame.setContentPane(fullScreenFrame.getContentPane());
windowedFrame.pack();
windowedFrame.setVisible(true);
fullScreenFrame.dispose();
changeFrameFullScreenMode(Frame app){
GraphicsDevice gd = GraphicsEnvironment
.getLocalGraphicsEnvironment().getDefaultScreenDevice();
if (gd.getFullScreenWindow() == null){
app.dispose();
app.setUndecorated(true);
gd.setFullScreenWindow(app);
app.setVisible(true);
}else{ // back to windowed mode
app.dispose();
app.setUndecorated(false);
gd.setFullScreenWindow(null);
app.setVisible(true);
}
}