如何在每种屏幕上调整应用程序(JFrame)? [英] How to adjust an application (JFrame) with every kind of screens?

查看:57
本文介绍了如何在每种屏幕上调整应用程序(JFrame)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在开发 Swing 应用程序,该应用程序具有 JFrame 作为主体框架,并且其中包含很多 JInternalFrames ,当我将其安装在公司的每台计算机上时,似乎某些计算机的屏幕尺寸较小且较紧,然后希望我开发了应用程序的屏幕较小,这没有用,所以我问我是否可以调整我的应用程序应用程序(框架)适应各种屏幕尺寸,我正在使用 Swing API.

i have been working on a Swing application that has a JFrame as principal Frame and it contains a lot of JInternalFrames inside of it , and when i installed it in every computer in the company, it seems that some computers screen size is lower and more tight then the screen in wish i had developed my application, and that is not useful, so i am asking if i can adjust my application (Frames) to every kind of screen size, i am using Swing API.

谢谢.

推荐答案

您可以像这样检查屏幕大小:

You can check the size of the screen like this:

 Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();

然后,您可以决定要覆盖多少屏幕.说出屏幕尺寸的一半.

Then you can decide how much of the screen you want to cover. Say half the size of the screen.

 int h = screen.height / 2;
 int w = screen.width / 2;

然后将您的JFrame设置为新的高度和宽度.

Then set your JFrame to this new height and width.

myFrame.setSize(new Dimension(w, h));

当然,您将不得不进行一些实验,以了解适用于所有屏幕尺寸的尺寸.或者,您可以在启动时简单地最大化Frame.

Of course you will have to experiment a bit to see what size works for all your screen sizes. Alternatively you can simply maximise the Frame on start up.

这篇关于如何在每种屏幕上调整应用程序(JFrame)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆