0

Here's what my program looks like so far: enter image description here

Is there any way to make that gray title bar on the top transparent?

I tried setUndecorated() but that completely removes the red/yellow/green window buttons and doesn't let me drag the window around.

Incase you don't understand what I'm asking, in Objective C I was able to make the titlebar transparent in this program:

Images

Doug Beney
  • 310
  • 2
  • 13
  • Possible duplicate of [how can i change the color of titlebar in JFrame?](http://stackoverflow.com/questions/2482971/how-can-i-change-the-color-of-titlebar-in-jframe) – Yassin Hajaj Nov 21 '15 at 21:54
  • It's not really possible to do this in Java, at least not without a lot work and hacking and native code – MadProgrammer Nov 21 '15 at 22:28

1 Answers1

-1

You can use JFrame.setOpacity() and set a percentage from 0 to 1 to make the entire frame translucent. Then set the contents to opaque. More information here.

UsamaMan
  • 695
  • 10
  • 28
divandc
  • 149
  • 5
  • Sounds cool but I get the error `Exception in thread "main" java.awt.IllegalComponentStateException: The frame is decorated`. I made sure to put it before the `setVisible` call but it still didn't work. – Doug Beney Nov 21 '15 at 22:01
  • The OP doesn't want to make the window transparent – MadProgrammer Nov 21 '15 at 22:27
  • It seems like the frame must be undecorated in newer java versions for transparency to work. you can try the following: this.setUndecorated(true); this.getRootPane().setWindowDecorationStyle(JRootPane.FRAME); to remove the original title bar and create another one within the rootpane of the frame – divandc Nov 22 '15 at 10:16