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!!

Recommended Answers

All 2 Replies

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/

i feel ok with this code thank u!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.