Я хочу создать компонент Swing во время выполнения, используя цикл for в JPanel, пока он ничего не отображает.Пожалуйста, помогите мне.
Вот код:
private String [] DTS = new String[]{"Number","Text","Date","Image","Document"};
private String [] CONS = new String[]{"Not Null", "Primary", "unique"};
private void GenerateButton_actionPerformed(ActionEvent e) {
System.out.println(e.getActionCommand());
System.out.println(TableName.getText());
System.out.println(ColumnRange.getText());
int Length = Integer.parseInt(ColumnRange.getText());
JTextField [] FieldName = new JTextField[Length];
JComboBox [] DataType = new JComboBox[Length];
JComboBox [] Constraints = new JComboBox[Length];
try {
for (int i=0; i < Length; i++) {
FieldName[i] = new JTextField();
FieldName[i].setBounds(new Rectangle(35,150,200,20));
DataType[i] = new JComboBox(DTS);
DataType[i].setBounds(new Rectangle(35,150,200,20));
Constraints[i] = new JComboBox(CONS);
Constraints[i].setBounds(new Rectangle(35,150,200,20));
this.add(FieldName[i],null);
this.add(DataType[i], null);
this.add(Constraints[i], null);
this.validate();
}
} catch(Exception GE){
System.out.println(GE);
}
}