NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Java problem

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users
View previous topic :: View next topic  
Author Message
stefnijenhuis



Joined: 10 Jan 2011
Posts: 1

PostPosted: Mon Jan 10, 2011 7:55 am    Post subject: Java problem Reply with quote

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

PostPosted: Sat Jan 15, 2011 12:03 am    Post subject: Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo