简体   繁体   English

使用最大化按钮调整 JFrame 的大小

[英]resize JFrame with maximize button

im sure if there is a way, but if I have already have Jframes that work with the small screen.我确定是否有办法,但如果我已经有了可以在小屏幕上使用的 Jframe。 Is there a way to make the elements of the screen resize to fit a screen if it is maximized?如果屏幕最大化,有没有办法使屏幕元素调整大小以适应屏幕?

What I mean is, if the screen is 40x40, and the pictures etc are located on that screen size the way I like, but when I maximize the screen, then the 40x40 part of the screen will be the same size, and the screen will maximize to show the surrounding enlargement of screen without elements (basically looks like a surrounding huge gray area surrounding the original smaller screen).我的意思是,如果屏幕是 40x40,并且图片等以我喜欢的方式位于该屏幕尺寸上,但是当我最大化屏幕时,那么屏幕的 40x40 部分将是相同的尺寸,并且屏幕将最大化显示没有元素的屏幕周围的放大(基本上看起来像围绕原始较小屏幕的周围巨大的灰色区域)。 I want to be able to enlarge the screen while keeping the elements in the same distance proportions.我希望能够放大屏幕,同时将元素保持在相同的距离比例。

I hope anyone can get what am trying to write.我希望任何人都能得到我想写的东西。

You're probably setting the sizes of elements yourself using setPreferredSize() , setBounds() etc. while using setLayout(null) .您可能在使用setLayout(null)自己使用setPreferredSize()setBounds()等设置元素的大小。 Use a Layout instead which will handle the resizing of components automatically.改用 Layout 来自动处理组件的大小调整。

Read this tutorial .阅读本教程

Add a container inside of the frame that you are expanding, and add constant variables as the dimensions of the container.在要扩展的框架内添加一个容器,并添加常量变量作为容器的尺寸。 Put the images in the container instead of the frame.将图像放入容器而不是框架中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM