简体   繁体   English

如何制作分辨率免费的应用程序

[英]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 个基本布局管理器是:

  • BorderLayout边框布局
  • GridLayout网格布局
  • FlowLayout流式布局

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 个选项:

  1. Not to scale at all for performance reasons,出于性能原因根本不扩展,
  2. Scale using AffineTransform on your graphics.在图形上使用 AffineTransform 进行缩放。 But this is a different topics, your questions seemed more general about swing components.但这是一个不同的主题,您的问题似乎更笼统,关于 swing 组件。

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.

相关问题 Android如何使我的应用在分辨率小于480x800的设备上不可见 - Android how to make my app not visible for devices with resolution smaller than 480x800 如何使 Javafx 应用程序使用在 Scene Builder 中传递给它的屏幕分辨率? - How to make a Javafx app use the screen resolution that's passed into it in Scene Builder? 如何制作Google Play捐赠应用程序以附加到免费版本? - How can I make a donation app for google play to attach to the free version? 如何在全屏独占模式下设置Java应用程序的分辨率/系统分辨率? - How to set resolution of a Java app/the system resolution in fullscreen exclusive mode? 如何使 Java 程序 ide 免费 - how to make a java program ide free 如何维护应用程序的付费和免费版本 - How to maintain a paid and free version of an app 如何确保请求的图像分辨率不会抛出内存不足异常 - How to make sure requested image resolution will not throw out of memory exception 如何使ImageView变为屏幕分辨率的两倍 - How do I Make an ImageView twice the size of screen Resolution 如何使LibGDX应用程序以与浏览器框架相同的分辨率启动 - How to make a LibGDX application launch at the same resolution as the browser frame 如何使我的应用程序支持所有设备的分辨率 - how to make my application support for all devices resolution
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM