This week's book giveaway is in the General Computing forum.
We're giving away four copies of Learning Regular Expressions and have Ben Forta on-line!
See this thread for details.
Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Disabling the 'X' button of JDialog  RSS feed

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Does anyone know how to disable (or remove) the 'X' button (or 'close' button) on the title bar of a JDialog? I know how to set it to do nothing (via the setDefaultCloseOperation() method with DO_NOTHING_ON_CLOSE as the parameter), but I want it to look disabled...or not be there at all.
Thanks!
[ April 04, 2002: Message edited by: Jeff Wisard ]
 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the Java Tutorial there is a simpleExample of JOptionPane

The JOptionPane is a simple JDialog with all you need

 
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using Java 1.4 you can remove the exit button by calling setUndecorated( true ) and passing it a style of PLAIN_DIALOG.

Here's some example code...


-Nate
 
Jeff Wisard
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Nate. Unfortunately, we are still back in the jdk1.2.2 world. Is there another alternative?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nope... the setUndecorated() and setWindowDecorationStyle() methods have just been added with 1.4... In previous JDKs there is no way to change top level components like this...

Perhaps you could extend a JWindow and just draw your own titlebar on the top?

-Nate
 
Ranch Hand
Posts: 1170
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't call setCloseable(FALSE) on a JDialog?
you can disable it by setting "DO_NOTHING_ON_CLOSE" and intercepting the window closing event to do what you need to do there.
 
Jeff Wisard
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yea...this I already know. What I want to do is have the 'X' button disabled...so that it never even generates the event. I want the user to know, just by looking at it, that the 'X' button is disabled.
Better yet, I would like it to not even be available on the title bar.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!