1

I have this form where there are extendable controls like there's a textbox for the user to type and beside it is an add button which the user would use to add another textbox beneath the previous one.

My problem is i don't even know how to make that add button work so that another textarea/textbox would appear just beneath the previous control..im doing it in netbeans ide 7.0 and in design mode...

I have researching for quite a while now and i'm so confused already what to do..at least you could provide me with an idea not really the code.

oliholz
  • 7,447
  • 2
  • 43
  • 82
Ken Muyot
  • 11
  • 1

3 Answers3

1

You should create a Layout.

For your case (Form kinda layout) , it seems that you need GridLayout.

For example, please check this link for all type of layout or directly go to Grid Layout link.

Rudy
  • 7,008
  • 12
  • 50
  • 85
0

Since you're going to be dynamically adding controls to your form, you'd simply want to put in a panel where you want the textbox and the button. Inside that panel place your textbox and button, you'd probably not want to use netbeans to do this, and use a LayoutManager like GridLayout. Now you'lld want to connect your button to an ActionListener that adds a textfiield to the panel.

Varun Madiath
  • 3,152
  • 4
  • 30
  • 46
0

See the Nested Layout Example for an example of (amongst other things) adding components to a GUI dynamically.

Community
  • 1
  • 1
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433