0
我的问题有3个部分。JFrame大小,调整大小,全屏
- 我想知道,我怎么可以设置
JFrame
窗口是可调整大小,但微量的尺寸下可以去不了,所以用户不能让体积更小,那么最小尺寸。 - 我想知道,即使用户调整大小,我怎样才能将
JFrame
窗口设置为可调整大小,但仍然保持宽高比(16:9)。 - 我想知道,我怎样才能使程序变得非常全屏他点击一个按钮后,那么有没有边界,运行像游戏或东西(如果有任何具体的问题,我怎样才能将其恢复安全)。
感谢您的帮助和耐心,因为我的英语不够完美,而且还没有完善的Java知识。
提供的答案是有用的,并回答我的问题的一部分,但仍然大部分对我来说仍然是空白。
代码的一部分:
private void createDisplay() {
GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
frame = new JFrame(title); //setting the title of the window
frame.setSize(width, height); //setting the width and height of the window
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //make sure program closes down properly
frame.setResizable(true);
frame.setLocationRelativeTo(null); //the window will apparel on the center
frame.setVisible(true);
frame.setIconImage(Assets.ImageMap.get("icon"));
canvas = new Canvas();
canvas.setPreferredSize(new Dimension(width, height));
canvas.setMaximumSize(new Dimension(width, height));
canvas.setMinimumSize(new Dimension(gd.getDisplayMode().getWidth()/2, gd.getDisplayMode().getHeight()/2));
canvas.setFocusable(false);
frame.add(canvas);
frame.pack(); //resize the window a little bit so able to see all of canvas
}
全屏的[JFrame的可能重复Java](http://stackoverflow.com/questions/11570356/jframe-in-full-screen-java) –
请提供您尝试过的代码。 – ashiquzzaman33