9

I got a new 4K Monitor and everything looks amazing but coding with NetBeans is difficult. The controls are very small and a java frame looks very small.

I've seen some Stackoverflow posts about this problem and they said I should add a line in the preferences file so that hi-dpi mode is disabled but my java frame is still small.

Davis Broda
  • 4,102
  • 5
  • 23
  • 37
DirtyHarry
  • 93
  • 1
  • 7

5 Answers5

8

For those who land here in 2021.

I am using Netbeans 12.4 on Windows 10 and the solutions mentioned here did nothing for me.

What did work was setting the high DPI settings in Compatibility Mode like so:

enter image description here

Big thanks to the following post that set me on the right path, it offers a powershell command to do this automatically for all java exes: https://superuser.com/a/1276743/648833

gordonk
  • 435
  • 3
  • 13
  • Only answer that worked for me on 12.2 in 2021 on Windows 11. Text renders a little blurry this way, but it's better than it being so small I can't read it at all. – Rich Court Oct 03 '21 at 20:02
  • Excellent Solution.... The accepted answer did not work for me. – Umar Tahir Oct 15 '21 at 14:53
  • 1
    This is the appropriate solution for 2022. I had the same problem and this is what saved me. Thanks! – Akin_Glen Sep 29 '22 at 12:32
7

For those who land here like me in 2019.

Currently using Apache Netbeans 11 in a 4k monitor and changing the dpiaware option has no effect for me.

What worked is adding the option -J-Dsun.java2d.uiScale=2.5 to the file netbeans.conf just before -J-Dsun.java2d.dpiaware=true.

The indicted piece of the file:

netbeans_default_options="-J-XX:+UseStringDeduplication -J-Djdk.lang.Process.allowAmbiguousCommands=true -J-Xss2m  -J-Djdk.gtk.version=2.2 -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.java2d.uiScale=2.5 -J-Dsun.java2d.dpiaware=true -J-Dsun.zip.disableMemoryMapping=true -J-Dplugin.manager.check.updates=false -J-Dnetbeans.extbrowser.manual_chrome_plugin_install=yes -J--add-opens=java.base/java.net=ALL-UNNAMED -J--add-opens=java.base/java.lang.ref=ALL-UNNAMED -J--add-opens=java.base/java.lang=ALL-UNNAMED -J--add-opens=java.base/java.security=ALL-UNNAMED -J--add-opens=java.base/java.util=ALL-UNNAMED -J--add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED -J--add-opens=java.desktop/javax.swing.text=ALL-UNNAMED -J--add-opens=java.desktop/javax.swing=ALL-UNNAMED -J--add-opens=java.desktop/java.awt=ALL-UNNAMED -J--add-opens=java.desktop/java.awt.event=ALL-UNNAMED -J--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED -J--add-opens=jdk.jshell/jdk.jshell=ALL-UNNAMED -J--add-modules=jdk.jshell -J--add-exports=java.desktop/sun.awt=ALL-UNNAMED -J--add-exports=java.desktop/java.awt.peer=ALL-UNNAMED -J--add-exports=java.desktop/com.sun.beans.editors=ALL-UNNAMED -J--add-exports=java.desktop/sun.swing=ALL-UNNAMED -J--add-exports=java.desktop/sun.awt.im=ALL-UNNAMED -J--add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED -J--add-exports=java.management/sun.management=ALL-UNNAMED -J--add-exports=java.base/sun.reflect.annotation=ALL-UNNAMED -J--add-exports=jdk.javadoc/com.sun.tools.javadoc.main=ALL-UNNAMED -J-XX:+IgnoreUnrecognizedVMOptions"

Thanks to ron190 that help us pointing this out:

Use -Dsun.java2d.uiScale=2.5 instead: superuser.com/a/1194728/465745

  • Oh my god thank you so much, it's exaclty what was working for me. Everything else failed. – miqwit Jan 21 '20 at 11:43
  • It seems to ignore the fractional part. I tried 1.5 and it looked the same as one. Once I tried 2 or bigger the scaling changed. I was hoping for 1.5 but 2.0 is better than 1.0 for me. – Allen Nov 02 '20 at 15:30
  • Anyone landing here in 2021: Neither solution is working for me with Netbeans 12.3 in Windows 10. If you have a solution it would be much appreciated... – gordonk Aug 09 '21 at 09:26
5

Try to edit NETBEAN_HOME\etc\netbeans.conf and set -J-Dsun.java2d.dpiaware from true to false.

-J-Dsun.java2d.dpiaware=false
Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
0

If you are on Linux, other than trying to set

-J-Dsun.java2d.uiScale=2

make sure that you are using jdk 11+, as jdk 8 does not seems to pick up that config

0

I am on windows and using ney beans 8.2 with JDK 8. None of the above approaches works for me.

For me, the best route is to add --fontsize 32 at the end of the netbeans_default_options variable:

enter image description here

You can use whatever font size you like. Remember to change the editor font size to a larger value at 1st boot. The code navigation bar beneath the editor area looks strange, but enough for me.

enter image description here

Wesley Ranger
  • 770
  • 1
  • 7
  • 26