I'm using the Processing PDE on my Ubuntu laptop, which has a high resolution display. The Processing PDE does not scale properly, as the rest of the system does. I can of course change the font in the editor, but the menus, console, ... are really tiny. I think PDE is a Java Swing application.
Is there a way (command line flag? environment variable? ...?) which allows increasing of the "system" font size in the applications?
The Processing editor is indeed a Swing application, and Swing applications have trouble with high resolution displays.
I haven't found a reliable fix for this yet, but you can widen your search to "java swing high resolution display" or something similar, as this problem is applicable to all Swing applications, not just Processing. It's also not just a problem with the font size. I've noticed that button sizes and whatnot will also be very small.
I know jEdit suffers from similar issues, as did eclipse until this latest version. You might look into what eclipse did to fix it on their end.
Honestly my fix has just been to lower my resolution to something that doesn't require scaling. That's not an optimal solution, but it works. I'd be curious to hear if you find a more reliable workaround.
See also:
How can I scale fonts on a high resolution screen?
How to set the DPI of Java Swing apps on Windows/Linux?
https://superuser.com/questions/988379/how-do-i-run-java-apps-upscaled-on-a-high-dpi-display
Related
I have created a program using Java 8 that utilises a Swing GUI in the Eclipse IDE. To scale images and icons to appropriate sizes, it gets and uses the screen resolution. Upon compiling the program within Eclipse, the program displays perfectly fine, and everything seems to operate as it should. However, when I export the project as a "Runnable Jar", and run the program, the image scaling and the program look and feel are all off.
Upon further investigation, it appears that the runnable jar was returning a screen resolution that is exactly 2.5x less then that in eclipse (which is the actual resolution - 3840x2160 vs 1536x864). There is circumstantial evidence across the internet that Java 8 Look and Feels (or something of the sort) don't support HiDPI screen scaling. There are scattered solutions that claim to fix the problem, like updating to Java versions past 8, or by adding arguments to the jar compilation (whatever that means). This is already confusing to a Java novice, and it is only made more confusing by the program being displayed perfectly when run/compiled within the Eclipse IDE.
My question is whether anyone knows how to get a program compiled in Java using Swing to scale correctly on an HiDPI screen, and what the process is that I need to follow to compile a working program?
EDIT 1: Something interesting to note is that in my Windows settings, the "Scale and Layout", "Change the size of text, apps, and other items" is set to exactly 250%, meaning that this setting is obviously the cause of the scaling issues I am encountering. Does someone know how to bypass this setting from within the program, or why it works when I run it through Eclipse?
Java 8 does not support High DPI. On Windows, it runs in DPI unaware mode and relies on Windows to stretch the window bitmap to the scale set for the monitor in the settings. It means the UI of the application looks blurry when displayed on a High DPI monitor.
Later versions of Java, Java 11 and above, support per-monitor High DPI settings. The UI of your application is correctly scale up according to the settings, the text remains crisp. For the icons and images to remain crisp, you should use MultiResolutionImage or its basic implementation BaseMultiResolutionImage to provide higher resolution alternatives.
You should not base your images based on the screen resolution but rather on the scale set for a monitor. For example, a Full HD monitor 1920×1080 with 150% scale has the effective resolution 1280×720, it is the effective resolution that Java reports to you.
How can I make my Java Swing app GUI scale properly to users on high-DPI screens?
See the screenshot below. At the top you can see how tiny the app looks compared to Ubuntu's file explorer icons and gedit. In the bottom left you can see roughly what size the app should look like (and does look on regular DPI monitors). So I'm looking for a way to scale the GUI of the app properly when a high DPI monitor is in use. For example, gedit looks the same on both regular DPI and high DPI monitors. I want my app to behave like this.
Here is source code for the app: https://github.com/baobabKoodaa/baopass
This is an extremely common problem affecting many apps. Roughly half of the apps I run on Ubuntu are scaled properly without any actions from the user, the other half are not scaled and look really tiny. Note that I'm mainly looking for a solution that doesn't require actions from the user (although any help is appreciated at this point - I haven't found any ways to scale it at all).
According to this scaling should already work out of the box. It doesn't. I'm not sure if this is a bug or if there is some additional step I'm supposed to do besides running the app on Java 9?
You have to tell the drawing libraries to scale the app up.
GDK_SCALE=2 ./application
Will have the appropriate information set in the environment and the widgets will render scaled up such that each pixel effectively takes four pixels of footprint.
Note that the splash screen (if you use Java's splash screen support) isn't presented after the entire Swing libraries are loaded, so it won't scale regardless of the settings you attempt.
In some platforms, like the Linux distribution of Fedora, partial scaling is also possible, such that you can set GDK_SCALE=1.5. Just keep in mind that it's not universally available, and it is not settable to any scaling ratio you might want.
Finally, the older JVMs ignore this setting completely, so if you aren't launching with Java 9 or higher, odds are it won't work. And, of course, the way that things are tweaked for older JVMs and different operating systems tend to vary (if they work at all).
It looks like you're using Linux. You can use a command line switch
java -Dsun.java2d.uiScale=2 -jar some_application.jar
From https://wiki.archlinux.org/index.php/HiDPI#Java_applications
I have an old .jar file that creates a main window with some textboxes for settings.
The problem is that some textboxes doesn't appear in the window (but they exist), if you lower the computer screen resolution they appear, but with higher resolutions, they disappear.
I tried to decompile the .jar file, but no success...
Since I cannot resize the window in any way (size seems to be fixed), is there a way to force it to be resized or set some Java VM parameters for this purpose?
The loader is "JarRsrcLoader". I attach an image showing the problem in Win10:
(They are not only cut, there are more textboxes).
I asked Mr Google for a Windows tool to make unresizable windows resizeable. Got several matches, here is a short list:
http://www.howtogeek.com/howto/11799/turn-non-resizeable-windows-into-rezieable-windows/
https://www.raymond.cc/blog/how-to-resize-an-unresizable-window-or-dialog-box/
http://www.ghacks.net/2012/06/18/resize-windows-with-fixed-sizes/
I actually found a way to scale the Java application to a lower resolution and see it adequately, only for Linux (but it was what I was searching).
From this source (askubuntu.com): script to fix scaling of java applications.
It provides python scripts to adjust the resolution of certain applications (statically and dynamically) when opened (on a high dpi screen). This solution works for my problem.
We have a rather complex application that needs as much screen real-estate as it can get, naturally the retina display Mac Books are excellent for this purpose.
However, it seems that in Swing those devices use points rather than pixels. They allow me to change the icons to higher resolution versions as discussed here. But since we do a lot of complex graphics and components overlays I want to just use "real pixels". To be clear I am not interested in fixing blurry images or icons (not practical in my case) just to disable the pixel doubling.
There is this interesting (albeit hacky) option I found thru this question.
To my knowledge this is not possible as of JDK 1.8. The only workaround is to detect retina and use the scale affine transform when drawing.
However, detecting retina seems to be a problem since the only option that seems to be available isn't on a per monitor case which is probably not a good solution:
How can I detect whether a Mac has a Retina display from Java?
I have a Swing Application that currently has the feature setAlwaysOnTop(true); and is docked to the top of the screen.
Now i can't find a way for other windows (Browser, IDE) to maximize in respect of my application.
To make myself clearer here is a picture:
As you see, currently the maximized window is behind my Application.
I don't want other applications to expand behind my application; just like maximizing a browser won't expand it past the Windows taskbar.
How can i realize the desired behaviour with JAVA?
If not possible directly with/in Java, are there other ways to achieve this?
N.B.: The App only has to work on Windows 7.
I guess the reason for my lack of search results was my inability to describe this behaviour. Any hints would be appreciated.
Thank you for your time.
It is called an Application Desktop Toolbar
The system prevents other applications from using the desktop area used by an appbar
Which is very Windows-specific, making it difficult in pure Java.
Perhaps jdeskbar could be an option if you really have to do this in Java and not a more "Windowsy" language
EDIT: According to the jDeskBar project wiki, the current release is broken. Maybe it can be picked apart?