954,545 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

netbeans java built in GUI

im creating a prototype for a hotel using netbeans ide 7.0. I used the drag and drop in designing the buttons, panels, label etc... then what i want to happen is when the button is clicked a jpanel/ jframe that i did will appear. How would i do that? I don't even know whats that called so i am having a hard time searching it in the net. All help is appreciated. Thank you.

stakeMyHeart
Newbie Poster
23 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
 

you mean a second screen?
MySecondFrame sFrame = new MySecondFrame();

stultuske
Posting Sensei
3,137 posts since Jan 2007
Reputation Points: 1,114
Solved Threads: 433
 
you mean a second screen? MySecondFrame sFrame = new MySecondFrame();

im a noob in this. please bear with me. if you would be so kind to put it in step by step.

what i did was: created new desktop application named desktopApplication1. placed a button in the jPanel. the button's labelled as jButton1 and variable name as jButton1. Created a new jPanel within the same package. placed a button in the jPanel. the button's labelled as back.

what i want to happen is: when jButton1 is clicked the other jPanel will appear. when the back button is clicked it will return to the original jPanel.

stakeMyHeart
Newbie Poster
23 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
 

that's great: the solution to step one is in my previous post. (well, I did use a JFrame for both parts here) but just add a JPanel to the JFrame and you're golden :P
for the second part: check if you can find something like a dispose method for a JFrame

stultuske
Posting Sensei
3,137 posts since Jan 2007
Reputation Points: 1,114
Solved Threads: 433
 
that's great: the solution to step one is in my previous post. (well, I did use a JFrame for both parts here) but just add a JPanel to the JFrame and you're golden :P for the second part: check if you can find something like a dispose method for a JFrame

ok, lets do it slowly and carefully.

im gonna put this:
MySecondFrame sFrame = new MySecondFrame();

inside this private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {}

but im going to change MySecondFrame to the name of my jpanel which is jPanel1

but what is sFrame? is that a random name?

stakeMyHeart
Newbie Poster
23 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
 

that's the name you choose.
it's like you when you say:
int counter = 0;
counter is just the name of your variable, and just like that you can have sFrame, mySecondFrame, ...

stultuske
Posting Sensei
3,137 posts since Jan 2007
Reputation Points: 1,114
Solved Threads: 433
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: