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.
Related
I use Windows 7 and have personalized the display to zoom in to medium setting (125%), making icons on the desktop bigger etc. Now when I changed from jdk8 to jdk11 I discovered the java applications are affected by this. What's going on and how do I avoid this?
So e.g. if I just create a simple JFrame and draw an image to it the frame is bigger than it should be, and the picture looks terrible.
Java 9 introduced support for scaling in high-dpi displays: http://openjdk.java.net/jeps/263
That would explain why you see this behavior change when going from jdk8 to jdk11.
Try the suggestions in this answer: https://stackoverflow.com/a/48623068/701303
(for swing: -Dsun.java2d.uiScale=1.0; for javafx: -Dprism.allowhidpi=false)
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
When I launch a java application using Swing for the GUI, I notice on Mac that Swing still renders the "old" Mac UI (10.9 and older). Since Oracle is now responsible to write the JRE for Mac OS X - where can I find any new UI?
Or are there any alternatives out there?
This spiked my curiosity since it also bothers me.
#MadProgrammer appears to be correct. Acoording to the Oracle's page about Look and Feels, HP, IBM and Apple provide their own Look and Feels.
To my understanding, this clears Oracle's responsability over the out of date L&F, and transfers it to Apple itself.
The only foreseeable option is to wait for updates...
I have just started working with JavaFX and have come to an obstacle. When I open SceneBuilder it renders very strangely. When the window is restored it seems zoomed in, and when maximized it looks better, but still not quite OK and inoperable.
The same goes for HelloWorld example that I created, and examples I found on internet, so I think it is something systemic. I have tried with Java 7u71 and with Java 8u25. No change. Please help if you know how to fix this.
After reading system requirements (http://www.oracle.com/technetwork/java/javafx/downloads/supportedconfigurations-1506746.html) I came across this line:
To avoid rendering issues on Windows platforms, upgrade the ATI driver to Catalyst 11.09 or later.
If you have a old laptop like I do (with ATI FireGL V5200 and ATI driver 8.561.0.0), try to disable HWA. I did this by setting JAVA_TOOL_OPTIONS in Windows Environment variables. See answer: How to disable or bypass Hardware Graphics Acceleration(Prism) in JavaFX
For Java 7: JAVA_TOOL_OPTIONS=-Dprism.order=j2d
For Java 8: JAVA_TOOL_OPTIONS=-Dprism.order=sw
My goal is to make a simple GUI which almost look like this attached screenshot.
But while using Awt, Swing i have never found yet such combo/buttons nor i have found something like transparent window which showing my desktop background.
I am very desperate to make something similar, but i am not sure which framework i can use?
Can i do this above UI, with GWT? or is there something else?
Java has always supported translucent windows on Mac (from at least OS X 10.4 but probably way before that too).
However on Windows you need at least Java 1.6.0_10 to be able to do translucent windows directly from Java.
If for whatever reason you're stuck with an older Java you can use JNA. They've got examples as to how to create translucent windows on OS X, Windows and Linux and these examples work even on older JVMs.
As I type this JNA is located here:
https://github.com/twall/jna
Here's the code for their alpha/translucent example (where you can drag a picture with an alpha channel, like a PNG with an alpha channel and then choose the opacity):
https://github.com/twall/jna/tree/master/contrib/alphamaskdemo/com/sun/jna/contrib/demo
Now what you want to do can be done but there are gotchas: you need to be careful about several things. For example mouse events: if you want catch them or not when they happen on an area that is "fully transparent" (if you want to catch them, you can cheat and make your translucent window nearly --but not fully-- transparent).
What you want to do is a bit like a HUD: there are definitely HUDs done in Java but as far as I know they weren't build using GUI builder tools. You'll probably have to code it manually (or at least some part of it manually).
See this: How to Create Translucent and Shaped Windows