I need some help, I'm new to java, so probably I will have to change a lot of things. I'm having this result:
[Goya, Scoop 2000 W, 123]
And if I try to add more, it will display:
[HMI, Scoop 2000 W, 123]
[HMI, Scoop 2000 W, 123, Fresnel, Set light 1000 W De Sisti, 124]
[HMI, Scoop 2000 W, 123, Fresnel, Set light 1000 W De Sisti, 124, Goya, Set light 1000 W De Sisti, 456]
And what I actually need is something like that:
[HMI, Scoop 2000 W, 123,]
[Fresnel, Set light 1000 W De Sisti, 124]
[Goya, Set light 1000 W De Sisti, 456]
Here is my code:
Component[] componente = painelMain.getComponents();
list = new ArrayList();
for (int i = 0; i < componente.length; i++) {
if (componente[i] instanceof JTextField) {
JTextField textfield = (JTextField) componente[i];
if (!"".equals(textfield.getText())) {
list.add(textfield.getText());
System.out.println(list);
}
} else if (componente[i] instanceof JComboBox) {
JComboBox combo = (JComboBox) componente[i];
if (!"".equals(combo.getSelectedItem())) {
list.add(combo.getSelectedItem());
}
}
}
}