I am creating an GUI application in java that uses input from the user and dynamically sets up textfield in my jFrame with default names like jTextField1,jTextField2 etc
My projects demo is as follows:-

1) It accepts number of rows and columns from combo box.
2)It should set the number of columns and rows as per the selection of
user. (ie it should dynamically create Jtextfield objects on the
JFrame)
Can i dynamically setup these commands inside a looping statement and create the number of textfields i need :-
private void initComponents() {
jTextField1 = new javax.swing.JTextField();
jTextField2 = new javax.swing.JTextField();
}
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
Or is there any other methods to do the same.
Is this Possible in any other languages like javascript or html.
Any help is appreciated !
Your approach is right. You loop through the indexes and create the new components (Java GUI objects) and add them to the container.
Remember to either check existing components or
remove()/removeAll()them.UPDATE:
When you create a Container you usually define a LayoutManager (I am more familiar with
GridBagLayout, butXYLayoutcould be useful for you). When adding a component to a Container, you have a method that allows an extra objectconstraints; that object is passed to the layoutManager to know where / how to draw the component added.Of course, each different layoutManager uses its own different constraints, so for the
GridBagLayoutI pass aGridBagConstraintsobject. In your example, to build a row, all the fields except the ones would be added by a default GridBagConstraints; the GridBagConstraints in the last row would haveto notify the layout manager that it is the last item in the row.