Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

loading a JFrame Form from a button in a JPanel

Posted on 2005-03-08
9
Medium Priority
?
1,322 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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month12 days, 3 hours left to enroll

564 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