NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
saman0suke
Joined: 05 Oct 2011 Posts: 1
|
Posted: Wed Oct 05, 2011 11:01 pm Post subject: How to add more components to a generated jFrame? |
|
|
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: 605 Location: Simpsonville, SC
|
Posted: Fri Oct 14, 2011 6:33 pm Post subject: Re: How to add more components to a generated jPanel? |
|
|
| This is the wrong forum for Swing GUI based questions, please use the |
|
| 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
|
|