I want to add and remove JTextField
controls dynamically using a combo box.
I have a combo box from 1 to 10. For example I press 3 to add 3 text field it works great. But when I press a second time (2) I want to delete the last text field.
This is my code:
LineBorder a =new javax.swing.border.LineBorder(Color.black);
String g =(String) nbparam.getSelectedItem();
int x = Integer.parseInt(g);
for(int i=0;i<x;i++){
c=new JTextField();
c.setText("Paramètre"+(i+1));
c.setBorder(a);
c.setSize(200, 28);
c.setLocation(30,20+43*i);
jPanel3.add(c);
jPanel3.revalidate();
jPanel3.repaint();
}