Hi, I have a JFrame in where I need something like a JTextfield to enter a value, say 14.
Once 14 has been entered, I need to be able to enter 14 strings.
I could possible create a JPanel inside a scroll pane that has 14 JTextfields,
or possibly use a table, but that table would have to have 14 rows, which can only be known
if the first value entered triggers something to create this.
I'm wondering what other people would do here, I'd like an effective solution, I don't know if there is any
component that can help. I currently just enter the values on 1 line separated by commas, but say you didn't
enter the right amount, its not very user friendly that way.
You can configure your spinner with a SpinnerNumberModel When the user changes any value, you can retrieve the selected number and dynamically populate your panel with the required number of fields.
I personally would prefer using text fields over table as text fields are more intuitive for the user.
PS. Don't forget to invoke revalidate and repaint (in that order) after you are done adding the fields to panel to get them to display properly.
The only thing is, it would be kind of nice to see the values you've entered at the same time, like you would with a bunch of text fields, but there could be an arbitrary number of textfields which makes it awquard.