How to remove the "X" closing button from a JDialog box?

How to remove the "X" closing button from a JDialog box?
i don't want to just disable the closing action writing my own event handlers.
I don't want the 'X' button to be seen at all.
LVL 1
sharath_kulalAsked:
Who is Participating?
 
TimYatesCommented:
That should show the title dialog..

    JDialog dlg = new JDialog( new Frame(), true ) ;
    dlg.setUndecorated( true );
    dlg.getRootPane().setWindowDecorationStyle( JRootPane.PLAIN_DIALOG );
    dlg.setTitle( "Test Dialog" );
    dlg.setSize( new Dimension( 320, 200 ) ) ;
    dlg.show() ;

Shows the title bar...but no close button...

0
 
TimYatesCommented:
0
 
TimYatesCommented:
Something like:

dlg.setUndecorated( true );
dlg.getRootPane().setWindowDecorationStyle ( JRootPane. PLAIN_DIALOG );
0
 
sharath_kulalAuthor Commented:
But i want the title bar to be displayed
0
 
TimYatesCommented:
you mean the system title bar?

You can't get rid of the system close button...that's put there by the system...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.