[英]JFrame size, resize, fullscreen
My question have 3 parts. 我的问题分为三个部分。
JFrame
window to be resizable, but can not go under a minim size so the user cant make it smaller then the minimum size. JFrame
窗口设置为可调整大小,但不能设置为最小大小,因此用户无法将其设置为小于最小大小。 JFrame
window to be resizable, but still keep the aspect ratio (16:9) even if the user is resizing it. JFrame
窗口设置为可调整大小,但是即使用户正在调整它的大小,仍要保持宽高比(16:9)。 Thanks for your help and patient for my not perfect English and not perfect Java knowledge. 感谢您的帮助和耐心,因为我的英语水平还不太好,Java知识也不很完善。
The provided answer is useful and answers part of my question, but still most of it still blank for me. 提供的答案很有用,可以回答我的部分问题,但对于我来说,大多数仍然空白。
The part of the code: 代码部分:
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
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.