Win a copy of Machine Learning with TensorFlow this week in the Artificial Intelligence and Machine Learning 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:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

How to disable JDialog close window button?

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Folks,
I have a JProgress Bar inside a Jdialog box, which has the close window button. I want to disable the close window button when the progress bar is progressing!.
ie I want to discolor it ideally(grey color).
How to do that?
Any suggestions,
NOTE:
DONOTHING_ON_CLOSE,HIDE_ON_CLOSE,EXIT_ON_CLOSE is not the required solution.
Pls Reply ASAP,
TAI,
Murali
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Murali,
This is just a suggestion. If you are using version 1.4 of java, have you investigated the setUndecorated() method in class java.awt.Dialog
http://java.sun.com/j2se/1.4.1/docs/api/java/awt/Dialog.html
Hope it helps.
Good Luck,
Avi.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
setUndecorated() makes the entire titlebar and border disappear... I'd just use setDefaultCloseOperation( DO_NOTHING_ON_CLOSE ); You (unfortunately) can't grey out the close button because it is provided by the native OS resources. I've even seen regualar MS apps that do this (have a non-closable dialog but do not grey out the close button).
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't understand -- can't you called button.setEnabled(false) when you want to disable it and button.setEnabled(true) when you want to reenable it? (Or better yet, call setEnabled() on the javax.swing.Action.)
- Keith
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Keith,
but what button do you want to disable ?
The close-button of JFrames, JDialogs etc.
are created from OS (heavyweight).
regards
Tim
 
Murali Obla
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks to All,
Thanks Avi, I'll try setUndecorated() method.
Keith,
I think you got confused with my question. I have meant the X(window close)button in the top right corner of the JDialog box. Any ways Thanks for your kind reply.
Nathan,
I have seen in some installation programs that the X button is disabled(meaning decoloured). How is that possible?. Is that the property of Install Shield program??. Why can't we do it in Java??.
Tim,
You are absolutely right, it is created by OS heavy weight!. Any possible ways Tim?.
TIA,
Murali
reply
    Bookmark Topic Watch Topic
  • New Topic