mbien commented on issue #6708:
URL: https://github.com/apache/netbeans/issues/6708#issuecomment-1814555288
> I am seeking guidance on how to programmatically iterate through all GUI
controls in the NetBeans Platform application and dynamically set the scaling
in both the x and y dimensions. Specifically, I am looking for information on
whether there are setters or APIs available for achieving this.
Although it is relatively easy to visit the whole UI hierarchy and access
all components, simply scaling them won't give satisfying results.
Your best bet is a combination of `sun.java2d.uiScale` and default font
size. The `sun.java2d.uiScale` property however won't work for all values, this
is resolution dependent (and might depend on other factors).
For example on 1080p it seems to only work with full integers: 2, 3
(anything beyond that is too large anyway, 2 is already very large). On higher
resolutions it should work for more scaling values since swing has more pixels
to work with (e.g you probably want factor 2 by default on 4k, which is what NB
is automatically setting I believe).
easy to test:
```java
public static void main(String[] args) {
// System.setProperty("sun.java2d.uiScale", "1");
// System.setProperty("sun.java2d.uiScale", "1.75");
System.setProperty("sun.java2d.uiScale", "2");
// System.setProperty("sun.java2d.uiScale", "2.5");
// System.setProperty("sun.java2d.uiScale", "3");
JFrame frame = new JFrame("ui scaling");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.add(new JButton("hello there"));
frame.setSize(400, 200);
frame.setVisible(true);
}
```
JDK is testing other values:
https://github.com/search?q=repo%3Aopenjdk%2Fjdk+sun.java2d.uiScale&type=code
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists