I use this part to make transparent the JFrame:

GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
		GraphicsDevice gd = ge.getDefaultScreenDevice();
		boolean opacity_supported = gd.isWindowTranslucencySupported(java.awt.GraphicsDevice.WindowTranslucency.TRANSLUCENT);
		if( !opacity_supported )
		{
			System.out.println("Your platform does not support opacity.");
		}
		else
		{
			setOpacity((float) 0.85);
		}

It works perfect on Windows. On the same machine I use also Ubuntu 11.10. I open the same project on Eclipse of Ubuntu, but it gives error on these methods:

java.awt.GraphicsDevice.WindowTranslucency.TRANSLUCENT

The error is:
The type java.awt.GraphicsDevice.WindowTranslucency is not visible


setOpacity((float) 0.85);

The error is:
The method setOpacity(float) from the type Window is not visible


I can not even built the project to test it. Java is cross platform. It must built the project and if the platform does not support the opacity it must give a warring from console. But the problem is i can eve built the project because it warns me about these both methods.

I try it on Java 1.6 and 1.5 both from Eclipse.

Thanks in advance...

Are both Windows and and Ubuntu on the same JRE/JDK version? WindowTranslucency was added in version 1.7


http://download.oracle.com/javase/7/docs/api/java/awt/GraphicsDevice.WindowTranslucency.html

I have Java 1.7 on Windows. But i set the environment libraries from Eclipse of project as 1.6. (also works with 1.5). When i set it as 1.4 it start to give me some error. Because it is old. That means my code works on 1.7, 1.6 and 1.5 java properly. I use on Linux Java 1.6. That means must work the project. Am i right ?

I have Java 1.7 on Windows. But i set the environment libraries from Eclipse of project as 1.6. (also works with 1.5). When i set it as 1.4 it start to give me some error. Because it is old. That means my code works on 1.7, 1.6 and 1.5 java properly. I use on Linux Java 1.6. That means must work the project. Am i right ?

I'm not sure how eclipse executes the generated jar. I think it uses the JRE available on the machine which should be at version 1.7 since I don't believe the JRE has multiple revisions installed at any given time. You may be able to compile under 1.5 and 1.6 but the virtual machine might be running version 1.7. So when the jar can not find the function you're asking for, it may reference the JRE which it is running under. This would make it seem like the program is working on version 1.5 and 1.6.

As for the error not being thrown on version 1.6 or 1.5 I wonder if the method was being developed and was not listed as an available method in the relating Java documentation.

I could be wrong in assuming how the jar is executed in eclipse or in the assumption that the machine's JRE is referenced if a unknown class is requested.

I would try uninstalling my windows JRE and installing the 1.6 version you want it to run on and see if it still works. If it does then we'll need another member's input on what the issue could be.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.