• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to make a frame modal

 
Lalit K Kumar
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9318
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use java.awt.Dialog/javax.swing.JDialog
 
Lalit K Kumar
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9318
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. It worked
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic