Created attachment 182446 [details] BeanShell window with small fonts and gui elements I was working with the just released NetBeans 15. I use a HiDPI display with a 2x scaling. When opening the program, it said: "Detected 2x HiDPI scaling in Xft.dpi setting; setting GDK_SCALE=2" Then it loads the IDE with GTK look and feel (plaf). It's nice and usable on a HiDPI display. The same trick for BeanShell editor can make it look better. IntelliJ IDEA also supports HiDPI screens. HiDPI article on IntelliJ docs: https://intellij-support.jetbrains.com/hc/en-us/articles/360007994999-HiDPI-configuration
Using the below parameter, one can change the scaling for a Java application via JRE startup parameters: java -Dsun.java2d.uiScale=2.0 App Java 9 might be required for this option. https://openjdk.org/jeps/263 I have tested the above parameter by adding it to the LibreOffice settings. I went to "Tools > Options > Advanced > Parameters", then added "-Dsun.java2d.uiScale=2.0" as the parameter. After that, I opened the "Macros > Organize Macros > BeanShell", selected a macro from the tree, then clicked "Edit". In this way, the window was shown with 2x scaling. To fix the issue and achieve automatic scaling, one can detect the scaling via GDK_SCALE or other means in other platforms, and then apply the scaling factor using the uiScale parameter, which also accepts fractional values for the scaling. On the other hand, it would be possible to implement the scaling inside our application too. For example, IntelliJ IDEA has internal scaling capabilities: https://youtrack.jetbrains.com/issue/JBR-3757 Increasing the font size would be part of this approach.
For the look and feel, it is possible to use Java startup options. For GTK: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel -Dswing.crossplatformlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel It is also possible to change the look and feel after the startup: https://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html These are some of the usable plafs: com.sun.java.swing.plaf.gtk.GTKLookAndFeel com.sun.java.swing.plaf.motif.MotifLookAndFeel com.sun.java.swing.plaf.windows.WindowsLookAndFeel com.sun.java.swing.plaf.mac.MacLookAndFeel
Let's turn this into an EasyHack. The Java options are now set manually using the "Tools > Options > Advanced > Parameters" dialog. As a starting point, the relevant UI and code for setting parameters manually is inside these files: cui/uiconfig/ui/javastartparametersdialog.ui cui/source/options/optjava.cxx The solution should be able to set the Java parameters automatically depending on the platform specific options, including the scaling factor.
(The place where any general JNI JavaVMInitArgs options are set programmatically is initVMConfiguration in stoc/source/javavm/javavm.cxx.)