When I set my Netbeans look and feel to nimbus and a small font seems great .
But when I set the font size to 14(or bigger than) some size of texts are OK but others will be made smaller than like size 10(though I set the font size to 14).
the covered areas with green mean that the font within them are set great.
the covered areas with red mean than the font within them are set incorrect (smaller than gotten value)
Gtk THEME:
Nimbus Look And Feel :
OS : Linux Manjaro
Jdk : open jdk 14
Environment : GNOME
Netbeans : Apache Netbeans 12
"It probably happens only on Linux and might be a java SE problem not a Netbeans problem"
It seems that the problem is within the Java on linux as it has some problem with javafx media players in linux as well.
Also as I tested other look and feels the only problem is in the nimbus and I have to report it to Oracle.
Related
I'm working on a Java Swing project,
I have an issue with some component while running projects vs running the interface here's some screen shoot :
This look when I run only the jFrame
This is when I run A Frame that lead to this
and this when i run the full project
I want to know why this look difference and how to resolve it.
I'm Using netbeans 12.2 with jdk 15.0.2 on a windows 64 bit machine
Java Swing by default uses native GUI components. The upside of this is that when done correctly, your Java application will have a Windows style on Windows and a Linux on Linux etc. To get a fixed style, you can set the Java Look And Feel to a LAF that is always available, such as the built-in METAL LAF. This page contains much more specifics on Java Look And Feels, how to set them and even how to create your own if you wish.
If you set large fonts (for example, 125%, 120 DPI) on Windows, then it looks as if Swing of Java 9 first renders into a smaller image and then scales this image to the screen.
Text is still properly displayed. But 1 pixel lines are times 1 pixel or 2 pixels strong. A diagonal line is stepped. Icons are rasterized.
Are there any command line parameters or API to change this behavior?
Example Edit:
Using MenuSelectionManagerDemo from docs.oracle.com/javase/tutorial/uiswing/examples/components/
I ran that Swing MenuSelectionManagerDemo using Java 9 and Windows 10, and the issues you raised appear to be resolved. See the two screen shots below, where I ran with scaling set to 100% and 125% respectively.
As I pointed out in a comment to the OP, it looks like this was resolved by a JDK bug fix several months ago, which I assume was raised by the OP:
https://bugs.openjdk.java.net/browse/JDK-8174845
One other minor point worth noting is that changing the Windows setting from 100% to 125% is a change to "Scale and Layout", and will "Change the size of text, apps and other items". (i.e. It is far more than just a font change, as mentioned in the JDK bug response.)
I found that on Oracle Java 9,10,11,12 and Amazon Corretto Java LTS (jdk 11.0.2_9) and the rasterization problem with icons/pictures are still a valid case and not fixed! Is this bugfix merged to trunk really?
Last version where this problem is not occurred is Java 8.0_202 where still everything goes well.
I have written a Java Desktop Application that runs in Windows, Mac OS X, Ubuntu and Open Suse. I am having issues with is positioning thing differently in Linux.
I developed the application with NetBeans using the designer, it looks as I would expect in Windows and Mac OS X, but in the Linux distros certain label controls have shifted into different positions.
Is there a common reason for this?
Perhaps Linux uses a different font. One where letters have a different width.
You could try to explicitely set a specific font for your Look&Feel. It should be a font which is installed on all of your target platforms.
The most probable thing is that you use different Look and Feel for every platform. If you're developing in Windows you do layouts to fit for Window style only. But Linux has different L&F with different margins and font for GUI components. Metal style (basic for Linux) and its descendants (Nimbus and GTK+) have larger default system font and heights for components. I think, that must be a reason why you have shiftings.
The way to fix that is to check program looking in both platforms. I'd suggest to develop in Metal style because Windows has smaller fonts, as result, everything which fits in Metal will fit in Windows.
I'm assuming you developed the thing on Windows or Mac, that's why it looks "as expected". Can you compiling/running the code in your IDE on Linux and see how it looks?
My guess is that one of the implementations of the containers is flawed. I saw this sometimes when I did cross-development and mostly did trial-and-error modifications to fix it (by changing to use other classes). It also helped to have one developer working in Windows and another in Linux, so that we would easily spot and fix problem areas.
I changed the Layout style from 'Free Design' to 'Absolute'
I'm writing a Graphically intense application that renders a JLabel offscreen.
When I call the following line, ellipsis appear on the mac but not on the windows box.
g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
Now, I'm guessing that it's caused by Mac already doing some subpixel rendering of fonts, but I'd just like to confirm it.
Also, since on it's imperative that FRACTIONALMETRICS be enabled on windows (the app looks terrible otherwise), can anyone suggest a work around short of adding a check for not mac?
Thanks.
The RenderingHints for FractionalMetrics are concerned with rounding floats to ints when sizing or kerning fonts. The glyphs themselves are unaffected by this setting. You can read all about this at the Java 2D FAQ.
You are correct that Java on Mac OS X is enabling text anti-aliasing at a system level, and Windows is not, but there's no need for a Mac-only check. What you should do is set the TextAntiAlias RenderingHint on instead.
gfx.setRenderingHint(
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON
);
Java 6 supports ClearType font rendering which is much better on LCD screens than the anti-aliasing that was in Java 5. ClearType often needs to be switched on Windows XP; it's somewhere in the display settings in the Control Panel. Then you need to run your Java program with the correct command-line arguments to enable it (or insert them into System.setProperty() before you display any Swing components):
java -Dawt.useSystemAAFontSettings=lcd [...your gubbins here...]
I have a Java application using the Substance LookAndFeel with Windows as the the target platform and I want to increase the DPI setting of my application without changing the system setting.
I want to do this because I don't want to force the user to restart Windows and because many Windows applications seem to have problems with very high DPI settings (> 120)
PS: I'm aware that the Substance LaF allows to scale the font size at runtime, but that way only the height of my controls are scaled, not the width. I want my GUI fully scaled as it would happen if I set the system's DPI setting.
Don't know if that is possible. The look&feel would have to support it, and as far as I know, the Windows Look&Feel does not. Here's a hack which you may consider: Iterate through all the fonts defined in your look&feel and redefine them to be slighly bigger. Here is a code snippet that does this:
for (Iterator i = UIManager.getLookAndFeelDefaults().keySet().iterator(); i.hasNext();) {
String key = (String) i.next();
if(key.endsWith(".font")) {
Font font = UIManager.getFont(key);
Font biggerFont = font.deriveFont(2.0f*font.getSize2D());
// change ui default to bigger font
UIManager.put(key,biggerFont);
}
}
I suppose you could take this one step further and redefine scale borders proportionally as well, but that gets very complicated very quickly
So the actual answer seems to be: no you can't. That really is a bummer because it's a pain to test.
Yes you can, but you need to run it on JRE 9.
This is because the Java runtime declared itself to be "DPI-aware" but didn't really supported it for AWT and Swing. Java applications were sized and rendered based on pixels rather than being properly scaled, this included HiDPI displays.
Anyways, this has been recently solved.
See the issue JEP 263: HiDPI Graphics on Windows and Linux
and the upgrade.
So, increasing the font size does not work (because it does not increase the rest of the things); the jvm argument -Dsun.java2d.dpiaware=false does not work (because it was not really supported); and the manifest file + registry edit (for Windows) just does not work.
Solution: You need to run it on JRE 9 because it really supports this feature.