Jump to content




Recent Status Updates

  • Photo
      15 Sep
    Error

    Programming is something that I enjoy and want to make a career out of. But, I usually tend to start things and not finish them. Any advice on how I can finish what I start?

    Show comments (2)
  • Photo
      12 Sep
    FacetiousTurtle33

    Just joined. Really enjoy this sight. Excited to become a great programmer, and helper.

    Show comments (3)
View All Updates

Developed by Kemal Taskin
Photo
- - - - -

Dynamic Number Of Text Field


  • Please log in to reply
11 replies to this topic

#1 Hamed

Hamed

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 413 posts

Posted 17 April 2012 - 09:25 PM

Hello,
I am using jFrame and in my jFrame there is one text field which show number of text field in next step
now I have two problem
1-How to make multi step in jFrame?
2-How can make dynamic text fields? (How to manage values and ...)
3- all data in all step should be accessible?Is it possible?
  • 0

#2 Norm

Norm

    CC Addict

  • Senior Member
  • PipPipPipPipPip
  • 397 posts
  • Location:Eastern Florida
  • Programming Language:Java, C++, Assembly

Posted 18 April 2012 - 03:12 AM

What is a dynamic text field as compared to a normal text field?
  • 0

#3 Hamed

Hamed

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 413 posts

Posted 18 April 2012 - 05:02 AM

Please check my attached file.
at first step user enter number of fields and in second step I show him field.

Attached Images

  • 1.jpg
  • 2.jpg

  • 0

#4 Norm

Norm

    CC Addict

  • Senior Member
  • PipPipPipPipPip
  • 397 posts
  • Location:Eastern Florida
  • Programming Language:Java, C++, Assembly

Posted 18 April 2012 - 05:12 AM

See post at http://www.javaprogr....html#post64018
  • 0

#5 gregwarner

gregwarner

    Obi Wan of Programming

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1,576 posts
  • Location:Arkansas
  • Programming Language:C, Java, C++, C#, PHP, Transact-SQL

Posted 18 April 2012 - 05:31 AM

You're going to need a loop. Inside the body of the loop you will create a new JTextField and add it to your container. You can control how many text fields get created by manipulating the upper bound of the loop.
  • 0

ti-99-sig.png
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid


#6 Hamed

Hamed

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 413 posts

Posted 18 April 2012 - 07:49 AM

How can i manage steps?

You're going to need a loop. Inside the body of the loop you will create a new JTextField and add it to your container. You can control how many text fields get created by manipulating the upper bound of the loop.


  • 0

#7 gregwarner

gregwarner

    Obi Wan of Programming

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1,576 posts
  • Location:Arkansas
  • Programming Language:C, Java, C++, C#, PHP, Transact-SQL

Posted 18 April 2012 - 10:16 AM

With a 'for' loop.

Or am I misunderstanding your question?
  • 0

ti-99-sig.png
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid


#8 Hamed

Hamed

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 413 posts

Posted 19 April 2012 - 07:37 PM

With for I can manage number of field text but I need multi step form.
  • 0

#9 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2,562 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java, PHP

Posted 19 April 2012 - 10:03 PM

GUI editor, or code?
  • 0

#10 gregwarner

gregwarner

    Obi Wan of Programming

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1,576 posts
  • Location:Arkansas
  • Programming Language:C, Java, C++, C#, PHP, Transact-SQL

Posted 20 April 2012 - 05:13 AM

With for I can manage number of field text but I need multi step form.


Can you describe exactly what it is you're trying to do?
  • 0

ti-99-sig.png
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid


#11 Hamed

Hamed

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 413 posts

Posted 20 April 2012 - 07:14 AM

Please check :http://forum.codecall.net/topic/69390-dynamic-number-of-text-field/#entry627292
Images are clear
  • 0

#12 gregwarner

gregwarner

    Obi Wan of Programming

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1,576 posts
  • Location:Arkansas
  • Programming Language:C, Java, C++, C#, PHP, Transact-SQL

Posted 20 April 2012 - 07:51 AM

Images are clear, but your description is not. What do you mean by a "multi step form"?

I can create that example UI in your post with a few lines of code, but I have no way of knowing whether it satisfies your business logic requirements.

List<JComponent> labelList = new ArrayList<JComponent>();
List<JComponent> textFieldList = new ArrayList<JComponent>();
// Assume 'upperBound' is an int value containing the number of field copies you want.
for (int i = 0; i < upperBound; i++) {
    labelList.add(new JLabel("Field #" + Integer.toString(i+1)));
    textFieldList.add(new JTextField());
}
// Loop through labelList and textFieldList here and add them to your form or your layout manager.
// ...

There's a lot more to it, like sizing and positioning controls, but that's the gist of it.
  • 0

ti-99-sig.png
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
– Douglas Hofstadter, Gödel, Escher, Bach: An Eternal Golden Braid