NetBeans Forums

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

How to add more components to a generated jFrame?

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



Joined: 05 Oct 2011
Posts: 1

PostPosted: Wed Oct 05, 2011 11:01 pm    Post subject: How to add more components to a generated jFrame? Reply with quote

Hello, I'm developing a swing application with a jFrame, and into it I have a jPanel, using the Swing Builder, the generated code cannot be modified, but, I'm wondering how can I manually add components to the jPanel, for example I'm trying to add a jButton components but it does not work:

Code:
    /** Creates new form jFrame1 */
    public jFrame1() {
        initComponents();
       
        jFrame1 jf1 = new jFrame1();
        JButton newBtn = new JButton();
       
        newBtn.setText("test button");
        newBtn.setSize(100, 50);
        jf1.getContentPane().add(newBtn);
        jf1.pack();

    }


The method iniComponents() is the one created by Netbeans which cannot be edited, any help will be appreciated, thanks!!
Back to top
jyeary



Joined: 21 Oct 2008
Posts: 612
Location: Simpsonville, SC

PostPosted: Fri Oct 14, 2011 6:33 pm    Post subject: Re: How to add more components to a generated jPanel? Reply with quote

This is the wrong forum for Swing GUI based questions, please use the
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> Java EE 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