aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Opening a jPanel Form in jFrame form using NetBeans IDE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Opening a jPanel Form in jFrame form using NetBeans IDE" Watch "Opening a jPanel Form in jFrame form using NetBeans IDE" New topic
Author

Opening a jPanel Form in jFrame form using NetBeans IDE

Chiranthaka Jayakody
Greenhorn

Joined: Dec 25, 2012
Posts: 6

class 01

A jFrame form that includes a JmenuBar.

class 02

A jPanel form.

** All I want is to open the jPanel form when I click the one of menu items in the jFrame form. Both these forms are developed using the Auto generation in java swing using NetBeans IDE.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
CardLayout
Chiranthaka Jayakody
Greenhorn

Joined: Dec 25, 2012
Posts: 6
Michael Dunn wrote: CardLayout


Then how can I able to open my jPanel Form using this cardlayout please explain it with some coding.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
the code is in the tutorial

http://docs.oracle.com/javase/tutorial/uiswing/layout/card.html

basically, you have a cardLayout panel to which you add any number of panels.
your menuItem code 'shows' it's relative panel
Chiranthaka Jayakody
Greenhorn

Joined: Dec 25, 2012
Posts: 6
Michael Dunn wrote:the code is in the tutorial

http://docs.oracle.com/javase/tutorial/uiswing/layout/card.html

basically, you have a cardLayout panel to which you add any number of panels.
your menuItem code 'shows' it's relative panel


But my dear pal the demo shows about jPanel not about jPanel Forms. All i need to open the jPanel form using a jFrame form and a menu bar!
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> the demo shows about jPanel not about jPanel Forms.

well then, what's a jPanel Form?
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4529
    
    5

Chiranthaka Jayakody wrote:But my dear pal the demo shows about jPanel not about jPanel Forms. All i need to open the jPanel form using a jFrame form and a menu bar!

Looks like you need to gain an understanding of Swing coding before you mess around with advanced tools like a visual designer. Here's a good starting point: Creating a GUI With JFC/Swing (skip the second section until you have at least a fair understanding of the other sections).
Chiranthaka Jayakody
Greenhorn

Joined: Dec 25, 2012
Posts: 6
Michael Dunn wrote:> the demo shows about jPanel not about jPanel Forms.

well then, what's a jPanel Form?



Ok then I will explain what am I wanted!

1.) I created a class with some variables with the 'Private' Access modifier. I have put getter() & setters() appropriately to access those variables from another class.
2.) I created a JFrame Form (User Interface) that have some textfields, labels, some buttons on it. This UI is used to enter values to those variables in the previously mentioned class. I did that successfully also.
3.) Then at that class (not the UI) I will be doing some calculations using some methods & able to return some values.
4.) Now a new UI (2nd one) not the previously mentioned UI will be used to display the results of that calculations using some textfields on it!
5.) I will enter some values on the 1st UI and then I will click a button called 'Calculate'. After clicking the 'Calculate' button the 1st UI should be closed and the 2nd UI should be appeared with the results.

When I am searching through the web I was able to find that JFrame form act as atop level container and once it closed whole application will be exit. The recommendation was at there use jPanel form instead of JFrame form which act as a lower level container and use a jFrame form to access those jPanel forms using a menu bar at the jFrame form. Now I have done those things but didn't come the result as I wished.

This jFrame form & the jPanel form was developed using Netbeans IDE by Auto generating. I used netbeans ide 7.2

jPanel form declarations is at the below.



Thank you
Chiransj
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4529
    
    5

Chiranthaka, do you really expect someone to repeat the Swing tutorial here? Just follow the link I have given you and make a start on learning Swing.

Using a visual designer without first understanding Swing coding is like getting in to the deep end of a pool without first learning how to swim. Somebody may come to your rescue, but you still won't have learned how to swim.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> The recommendation was at there use jPanel form instead of JFrame form which act as a lower level container
> and use a jFrame form to access those jPanel forms using a menu bar at the jFrame form.

from your previous statement:
"the demo shows about jPanel not about jPanel Forms. "
it's quite apparent you have extremely limited knowledge of Swing.

the answer I previously posted is ideal, and if you cannot grasp it,
pay someone to write it for you.
 
wood burning stoves
 
subject: Opening a jPanel Form in jFrame form using NetBeans IDE