[英]How to make resolution free app
I have set 320x480 size for canvas/widget of app.我为应用程序的画布/小部件设置了 320x480 大小。 How can I make it resolution free.I have to draw some tips on particular location using AbsoluteLayout.If I change size of canvas/widget then the tips are displaying at wrong coordinates.
如何使其无分辨率。我必须使用 AbsoluteLayout 在特定位置绘制一些提示。如果我更改画布/小部件的大小,则提示显示在错误的坐标处。
You should not work with absolute layout.您不应该使用绝对布局。 Learn how to use other layout managers in Java.
在 Java 中了解如何使用其他布局管理器。 It can look complicated at the beginning but it's your only hope to get a resizable application without all the burden of managing size by yourself.
一开始它可能看起来很复杂,但这是您获得可调整大小的应用程序而无需自己管理大小的所有负担的唯一希望。 Layout managers are precisely done to handle components positionning whatever the size of the container is.
布局管理器精确地处理组件定位,无论容器大小如何。
The 3 basics layout managers are: 3 个基本布局管理器是:
A very usefull layout manager is BoxLayout (though the constructor is weird). BoxLayout 是一个非常有用的布局管理器(尽管构造函数很奇怪)。
Here is a good docs from SUN about layout managers . 这是来自 SUN 的关于布局管理器的好文档。
When you master this, and it's not so difficult, you can build almost any application in swing.当你掌握了这一点,而且它并不难,你可以在 swing 中构建几乎任何应用程序。
And if you work with custom components, I mean JPanel where you overrided paintComponent, then you should consider 2 options:如果您使用自定义组件,我的意思是 JPanel 覆盖了paintComponent,那么您应该考虑 2 个选项:
Oh, and by the way, I think you should really accept answers from people and vote for what answer helped you.哦,顺便说一句,我认为你真的应该接受人们的回答并投票选出对你有帮助的答案。 It's the minimal way to thank people here.
这是在这里感谢人们的最低限度的方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.