NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
stefnijenhuis
Joined: 10 Jan 2011 Posts: 1
|
Posted: Mon Jan 10, 2011 7:55 am Post subject: Java problem |
|
|
Hello people,
I need to make a Jbutton open up a new Jframe, let's say i got a button called settings and that one needs to open a new window also called settings and close the main window, or change the main window into the settings window.
Now my question is, is this posible in the GUI builder or do i have to do this in code? if in code can someone give me an example
Thanks |
|
| Back to top |
|
 |
netero
Joined: 25 May 2009 Posts: 207 Location: Switzerland
|
Posted: Sat Jan 15, 2011 12:03 am Post subject: |
|
|
Hello,
When you create the button with the GUI, in NetBeans you can click on the button which appears in the "Design" tab. And automatically, in the "Palette" Window, you should see the button properties.
There you see 4 options: properties, binding, events and code. If you select "Events", then you see a list of events, and you will have to select the "actionPerformed" event. This is the event that is generated when the user clicks on this button.
At this moment, click on the small icon near your actionPerformed button, and NetBeans switches automatically in the corresponding Source. You will see this:
| Code: | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
|
And in the place of the TODO you can place the code to open another frame as you like.
Bye
netero |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|