This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 8839
    
    7

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: 8839
    
    7

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to make a frame modal
 
Similar Threads
How to make a Jframe from minimum to maximum ?
how to Deiconified the JFrame????
How to exit JFrame2 when going back to JFrame1
Frame as MODAL
jsp + frames