- First create a Swing container to hold dynamically generating objects.
- Then set a layout for the container
·
dynPanel.setLayout(new
FlowLayout());
- Then create objects from components that you want to generate.
·
JLabel lbl =
new JLabel();
·
JTextField
txt = new JTextField(12);
4. Then modify those objects as you want.
·
lbl.setText(allName);
·
txt.setText(String.valueOf(allValue
+ "0"));
·
txt.setEditable(false);
5.
Then add
those objects to the panel.
·
dynPanel.add(lbl);
·
dynPanel.add(txt);
6. Then repaint the container
·
dynPanel.revalidate();
·
validate();