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.

Recommended Answers

All 5 Replies

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

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.

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

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?

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, ...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.