Open DawidLokiec opened 7 months ago
This might start with getting #3523 in a stable position for inclusion and then working with the font sizing or UI scaling covered in #6676 ?? cc/ @DevCharly thoughts on this?
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:
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
@mbien
Interesting. I didn't know that System.setProperty("sun.java2d.uiScale", x)
takes effect at runtime. I thought it always had to be passed to the JVM in the java
command invocation because programmatically setting it with System.setProperty("sun.java2d.uiScale", "2"
) (for example, in the static
block of a subclass of ModuleInstall
) has no effect in my NetBeans-based application. Is it possible to write a custom main
method in a NetBeans Platform-based application, or perhaps modify the existing one? If the latter, where can I find the main
method in the NetBeans Platform-based application?
Interesting. I didn't know that System.setProperty("sun.java2d.uiScale", x) takes effect at runtime.
it does only work if it is set before any UI is initialized, the code above is just an experiment for testing purposes.
...programmatically setting it with System.setProperty("sun.java2d.uiScale", "2") (for example, in the static block of a subclass of ModuleInstall)
your module is likely not loaded early enough, some UI might be already initialized
where can I find the main method in the NetBeans Platform-based application?
The Main class can't be customized
Description
Issue Description:
I am currently developing a NetBeans Platform-based application and am aiming to enhance accessibility by dynamically scaling (enlarging) all GUI controls. The goal is to provide users with visual impairments the ability to adjust the scaling of UI components dynamically.
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.
Proposed Solution: I propose introducing an enhancement to the NetBeans Platform that enables developers to programmatically scale GUI controls for accessibility. The enhancement could include the following:
API for Dynamic Scaling:
Iteration Through GUI Controls:
User-Adjustable Scaling:
Documentation:
Expected Behavior: Upon implementing this enhancement, developers should be able to use the provided API to iterate through GUI controls and dynamically set the scaling in both the x and y dimensions. This would facilitate the creation of more accessible applications, particularly for users with visual impairments.
Use case/motivation
No response
Related issues
No response
Are you willing to submit a pull request?
No