0

i m working on a project and i want to implement a java code such that if user enters a number say 5 then after submitting on the next frame 5 textboxes should be displayed??
please help me!!

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by bivashkumar41
0

well you simply creat 5 textboxes dinamically, there is no big deal:

int user_input  = getUserInput(); //your method to get this input
   int count = 0;
   while(count <= user_input){
      JTextField dinamyc_textfield = new JTextField();
      dinamyc_textfield.setVisible(true);
      dinamyc_textfield.setBounds(/*Do some math here to get the correct bounds*/);
      dinamyc_textfield.setName(String.valueOf(count));
      next_frame.add(dinamyc_textfield);
      count++;
   }

you might want to keep track of this dinamycally added textboxes by adding them into a LinkedList, to use them later

List<JTextField> my_fields = new LinkedList<JTextField>();
  my_fields.add(dinamyc_textfield);

with that you should be fine :)
Happy coding pal.

--------------------------------------
P.S: if you want to sign in, I'm designing a java online course, you will learn a lot
http://javazerotopro.com/

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.