Main Topics
Browse All TopicsI'm playing around with creating an application and I want to create a new window when a button is clicked. I'm new to creating swing apps so I'm wondering what the best way to accomplish this would be and what component would best suite. I have a listener setup (and it works properly - ie: I can print to the console on button click) however I don't know where to really get started with what type of component I should be using and basically how to open something that says hello world for starters...
The goal is to be able to click a button and be able to have a user enter information like an address or something and save it, and when saved close the window. I'm not too concerned on the saving part, other than being able to close the window. I would think since I'm gathering user info etc... a JDialog would not be best suited assuming they're primarily for status notifications whereas a user would click a "agree", "ok", "cancel" button or something when they read the message. So I'm thinking a JPanel or JFrame. What is the major difference and are one of these best suited for a small data entry window? And how would I display one over my main JFrame when a button in my JFrame is clicked?
Thanks in advance,
-tb55
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Thanks for the quick response! I have a JFrame opening now, however when I click the "Close" in the upper right, both windows close, not just the opened frame itself. Should I be setting a unique type of "setDefaultCloseOperation(
Business Accounts
Answer for Membership
by: objectsPosted on 2008-12-07 at 20:07:17ID: 23118715
You would use a JFrame (os a JDialog) and add form form to that window.
Diff between a JFrame and a JPanel is that a JFrame is a top level container. A JPanel needs to be added to a tot level container to be able to be displayed on the screen. ie. every window in your gui is accosted with a top level container.