?
Solved

loading a JFrame Form from a button in a JPanel

Posted on 2005-03-08
9
Medium Priority
?
1,319 Views
Last Modified: 2013-11-23
hi, I have a small java application that contains a  JPanel. In the JPanel I have a JButton. I also created a JFrame Form using NetBeans. Now I have added the ActionListener in my JPanel and all  I want to do is when I click on the button in the JPanel, I load the JFrame form. Right now I system.out.println a msg so the event handeling is working okay. I just wanna know how to instantiate the JFrame and make it visible. Any ideas?

 
0
Comment
Question by:tbarrawi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 92

Accepted Solution

by:
objects earned 800 total points
ID: 13492431
JFrame f = new JFrame();
// add whatever you want to your frame
f.pack();
f.show();
0
 

Author Comment

by:tbarrawi
ID: 13492523
thanks, I am sorry I missed one thing in my previous question, how can make the JFrame window that will popup to be always on top and I can't access the JPane unless I close the JFrame first?  
0
 

Author Comment

by:tbarrawi
ID: 13492559
it works, thanks, but now when I click the x to close the JFrame, the whole application closes. [I increase the points since its another question.]
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 92

Expert Comment

by:objects
ID: 13492561
you would need to use a JDialog instead of a JFrame to achive that.
0
 

Author Comment

by:tbarrawi
ID: 13492587
to keep it on top or the x close problem?
0
 
LVL 92

Expert Comment

by:objects
ID: 13492603
to keep it on top

to change the close behaviour use the setDefaultCloseOperation() method of JFrame
0
 

Author Comment

by:tbarrawi
ID: 13492674
"to change the close behaviour use the setDefaultCloseOperation() method of JFrame" how? I am a newbie here..
0
 
LVL 92

Expert Comment

by:objects
ID: 13492697
frame.setDefaultCloseOperation(....
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
Suggested Courses
Course of the Month11 days, 22 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question