How to get the font properties of titlebar in JOptionPane. I am using linux OS system. We can get font properties of other java component using getFont API but as titlebar is OS dependent (native), what is the way to get font properties of titlebar ?
You can't really control titlebar decorations on Linux before Wayland, which is not generalized yet, and even in a Wayland world that will depend on the desktop environment, its toolkit, and how much leeway it gives to individual apps.
Probably a lost cause if you add the Java/native toolkit barrier. Java is not even using GTK3 yet, I doubt GTK2 will ever get more than minimal Wayland love and exploiting Wayland from GTK3 will probably require deeper support than just a minimal GTK2 glue replacement.
You may have more luck with SWT.
OpenJDK GTK3 support
Related
When I installed inconsolata everything looked fine, however when I tried viewing it on netbeans it look like this:
I tried using both the ttf and otf versions and they both looked messed up.
Is this a java issue? Win 7 64 bit issue? Is there any way to fix this?
You could try disabling font antialiasing in NetBeans.
Open up your netbeans.conf
As part of the netbeans_default_options section add -J-Dswing.aatext=false -J-Dawt.useSystemAAFontSettings=off.
Edit: fvu also provided a helpful link to a relevant section in the NetBeans font rendering FAQ.
If you want to play around with NetBeans font rendering settings, take a look at http://wiki.netbeans.org/FaqFontRendering
Unfortunately, what this article concludes is that default font rendering settings provide the best possible experience. At least under Windows. I have tried all the possibilities with Inconsolata and defaults provide the the best look indeed.
As a workaround, you can try two things:
Decrease contrast of your color scheme, i.e. by decreasing lightness of a background and/or increasing lightness of your font. It makes font rendering issues less visible.
Use NegativeScreen: http://arcanesanctum.net/negativescreen/
You may find your experience improved, but this is up to your personal preference.
It's not just NetBeans, although it is probably not simply the Inconsolata font's fault either. There seems to be a problem at the level of the underlying Java system that NetBeans is built on. I say this because the exact same problem shows up in the IDEs created by Jetbrains -- IntelliJ IDEA, WebStorm, PyCharm, and possibly others.
Is there a way to scale all the Swing components in an app by a single factor? I have an existing Swing app, and I want to display all the components at double size. Is this possible?
EDIT:
I'm porting a Java Swing app to Sugar (OLPC XO Graphics Environment). I don't have accessibility functionalities. The machine has only one resolution of 1200x900 in a 7.5” display. So the components are really small and unreadable.
If you place
System.setProperty("sun.java2d.uiScale","2")
at the very beginning of your main method, this will scale the entire application by a factor of 2. Other scaling factors are possible. If have tried this successfully with openJDK 11 on Windows 7 and Linux with KDE, both with System Look and Feel. Windows does accept fractional scaling factors, KDE does not.
If you do not want to modify the source code, a command-line option to the jvm will have the same effect:
java -Dsun.java2d.uiScale=2 -jar myApp.jar
Unluckily there is no such standart feature in Swing.
Every component size in application is determined by layout of the container where that component is added and component's preferred/minimum sizes, provided by their UIs.
So the best way (as i see it) is to modify standart UIs, so they provide additional preferred size (doubled in your case). But you will have to do that separately for each component of a certain type (buttons/checkboxes/tables/trees/scrolls e.t.c.). Plus you cannot change the system UIs - you could only extend some cross-platform Look and Feel like Metal LaF and that won't be useful at all in case you are using native Look and Feel.
You can change some default L&F properties though, like font:
UIManager.put ( "Button.font", new FontUIResource ( new Font ( "Arial", Font.BOLD, 20 ) ) );
This specific case changes only buttons font. There are also a lot of other components font properties that you can find in any LookAndFeel class (for e.g. BasicLookAndFeel).
is possible to scalling the Swing JComponents by using Nimbus Look and Feel
is very complicated to modify Nimbus L&F, its Color, Insets, Bounds e.i., but in plain form without any issues
You can use J(X)Layer for this (see www.pbjar.org/blogs/jxlayer/ but site seems down at the moment). An example which builds on it can be found here: http://patrickwebster.blogspot.com/2009/01/scalable-jfreechart-applet.html
Is there a way to set DPI in Swing? For the whole application? And if there is, how do I set it to the value of the system DPI?
I guess there must be a way to do it, as I mentioned this feature must have benn added to NetBeans in some of latest versions...
Thank you for reading.
I think it would depend on the Look and Feel you're using.
As far as I know Substance LAF honors the current desktop DPI settings.
Here is some related info https://pushingpixels.dev.java.net/files/documents/7463/95862/dpi-bof.pdf
I have a little JWindow with a logo on it that users can drag stuff to.
I develop my application mainly on OS X. To get a transparent window i use
setBackground(new Color(0,0,0,0));
On a mac this works beautifully but I can't get the same effect on windows.
Is there any way to get a transparent window without using 1.6 specific features.
I need 1.5 compatibility.
Sadly, windows (previous to Vista at least) doesn't do this kind of compositing. There is however a workaround. Example code can be found at http://rabbit-hole.blogspot.com/2007/02/non-rectangular-windows-update.html
As of 1.5 Java does not support transparent windows.
This feature is introduced as part of 1.6.10 release.
See AWTUtilities class for more details.
Running a Java Swing program on Ubuntu Linux, I'm getting an odd bug where the font height is too large for the actual font size, that is, every piece of text (in menus, buttons, text areas etc.) has excess blank space underneath the text itself.
This does not depend on which font I select.
It also does not depend on the font size chosen - setting a larger size in an attempt to use up the extra space, just causes the excess space to scale with the font size.
It does depend on the operating system -- it works fine on Windows.
It also depends on the look and feel chosen -- it works with the GTK look and feel (which is otherwise not as attractive as the Metal look and feel, so I would prefer not to use that as a workaround if I can avoid it).
I can't find any mention of this on Google. Any ideas how to fix it?
Are you using SunJDK or OpenJDK? I think OpenJDK uses some other fonts and in general has problems with fonts and layouts. If you're using default install of eclipse, you're with gcj which is even more unpredictable. Try SunJDK.