• Post Reply Bookmark Topic Watch Topic
  • New Topic

Transparent JOptionPane

 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,
I have created a messageDialog:



Is there anyway to make this transparent/opaque, so the component
behind it, can be seen?

Thanks
 
Campbell Ritchie
Marshal
Posts: 52581
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't know.
You don't create a message dialogue with thast command; you show a dialogue from a static method.
I have never tried this, but JOptionPane has an inherited setOpaque() method, so you could try using an instance of JOptionPane rather than the static method, and calling setOpaque(false) on it.

Anybody else got any suggestions?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't do this with a JOptionPane, or a JDialog - because these are actually separate native windows. The best way to do this is to make something that looks like a dialog inside your original window and make it partially transparent. Then, you can make use of JGLassPane to trap any other events, so that only your fake "dialog" can be interacted with while it's being shown.
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems like too much hard work, but I did already consider making a new component(JPanel) and using setOpaque(true)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!