Hi,
I want to create a JDialog with a list of JTextField's in it. There will be two buttons on also. One plus (+) button and one minus (-) button. When pressed, the window should repaint with one JTextField more or less. There will be also othe componets on the JDialog, all in a GridBagLayout. For the moment, I have something like this:
private int number;
public Test() {
number = 4;
initializeComponent();
pack();
}
private void initializeComponent() {
GridBagLayout gbl = new GridBagLayout();
setLayout(gbl);
GridBagConstraints gbc = new GridBagConstraints();
// ...
for(int i = 0; i <= number; i++) {
gbc.gridy = i;
gbc.gridx = 1;
JTextField temp = new JTextField(1);
gbl.setConstraints(temp, gbc);
add(temp);
}
//....
}
// called when one of the buttons is pressed
private void changeNr(boolean plus) {
if(plus) {
number++;
} else if(number > 1) {
number--;
}
btn_min.setEnabled(nr > 1);
// DOESN'T SEEM TO WORK ?!
repaint();
}