GeeCON Prague 2014*
The moose likes Swing / AWT / SWT and the fly likes How to make a frame modal Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to make a frame modal" Watch "How to make a frame modal" New topic
Author

How to make a frame modal

Lalit K Kumar
Ranch Hand

Joined: Jan 29, 2004
Posts: 32
hi everyone,
I have two frames , say frame1 and frame2. whenever a button is clicked in frame1 , i want to display frame2 as a modal. can anyone tell me how can i do it.
thanks in advance.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8914
    
    8

Use java.awt.Dialog/javax.swing.JDialog


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Lalit K Kumar
Ranch Hand

Joined: Jan 29, 2004
Posts: 32
In the constructor of JDialog (or Dialog) we have to pass the name of the owner and a boolean value.but where to give the name of the window which i want to be modal? Do i need to implement some method of JDialog (or Dialog) to give the name of target window.
thanks
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8914
    
    8

According to the javax.swing.JDialog documentation, you pass it a reference to it's parent dialog/frame (in your example, frame1), an optional boolean to indicate modality and an optional String title.
Lalit K Kumar
Ranch Hand

Joined: Jan 29, 2004
Posts: 32
Thanks. It worked
 
GeeCON Prague 2014
 
subject: How to make a frame modal