• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to make a popup Window, not Menu

 
Bigglesworth Naruki
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to put a button on my panel that, when pressed, will generate a new modal window that I can customize just like a regular application JFrame.
I've looked at the Java Sun tutorials and the API docs, but for some reason I am just not seeing how to do this.
The only other requirement is that I can retrieve/set the values on the popup window's components even when it's not visible.
Surely this is simple, right?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The class you're looking for is JDialog. You can lay out components on a JDialog just like a JFrame. You can also access the values of fields on your JDialog if you create it in your current class, or if you create it in another class and add methods to return the values. To make it launch on a button click, all you have to do is create the dialog beforehand, then add an actionListener to the button that makes the JDialog visible.

-Nate
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!