Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How to make a popup Window, not Menu

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?
Posts: 4121
IntelliJ IDE Spring Java
  • 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.

You are HERE! The other map is obviously wrong. Better confirm with this tiny ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic