Change Font based on screen size change

痴心易碎 提交于 2020-01-07 02:33:22

问题


In my Java Swing application, I have buttons. If the screen size is changed, I want to change the font of my button text also.

How do I implement it?


回答1:


I believe that you need a JFrame window listener and simply change the button attributes there:

//global JButton button1 defined earlier
button1.setFont(new Font("<FONT NAME>", <FONT STYLE>, <FONT SIZE>))



回答2:


GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds() ?




回答3:


Thanks to all,

Based on listeners and frame size, border size and actual panel size I have figured font sizes for various screen size ranges.



来源:https://stackoverflow.com/questions/8181001/change-font-based-on-screen-size-change

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!