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'
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.
i had developed application in ubuntu using eclipse platform .i used our local language as displaying in gui forms.i used JLabel b = new JLabel("fonts of local lanuage(gujarati)");
i works properly in ubuntu but when i run this on windows it wont show properly means it displays like [][][][][][][].how to correct it.plz help me.
That may refer to Font. make sure you have fonts available in windows.
This is a link to a unicode to un-unicode converter. it may be useful
Yep the problem that you are facing is the font that is why when you run on windows it comes up like this
[][][][][][][]. The simplest solution to this is use a font native to windows such as Arial or Times New Roman.
I have asked this question on askubuntu thinking that it may be related to ubuntu but now that I think about it, it may rather be related to eclipse so I wanted to ask in here as well.
I'm using eclipse on my ubuntu 12.04 system. Currently the default font in eclipse is set to monospace (mostly) although my system monospace font defaults to ubuntu mono (checked from gnome-tweak-tool). I have found this in the eclipse documentation where it says
By default, the Workbench uses the fonts and colors provided by the operating system. However, there are a number of ways that this behavior can be customized.
I was wondering why eclipse is not using my system fonts. I can change the font from the preferences but there are a lot of different font settings for different places and I am using a few different eclipse's on my system so it would be nice to find something that would work globally.
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.
I extend org.eclipse.swt.widgets.Composite and create many widgets on it, (labels, table, text etc). The problem I am facing is that the labels' text is getting truncated on linux while it appears fine on windows. When I change the linux's font to gothic the truncation is little less but still there. Is there way to homogenize the windows and linux display. What could be the best font to use in linux in such a case.
More likely it is related to this eclipse bug which I just lobbied to have re-opened: https://bugs.eclipse.org/bugs/show_bug.cgi?id=151322
It sounds like you are using absolute positioning instead of dynamic layouts. (If this isn't the case, perhaps you could post code demonstrating the problem). Using a dynamic layout should ensure that controls are resized to accommodate their contents. (They're also great if you ever translate a product, because then you don't have to rejig every dialog for every language.)
To complete McDowel's answer, there is also a bug related to the way Linux check for wrapping label:
It is fixed since 3.4M7.
Even though it may not be related to your case, it would be useful to know which version of eclipse you are using and if you can reproduce your bug with the latest ones (like a 3.5M6)