I have a panel with multiple comboboxes in each row, I need to fetch the combobox values from it.
this is my code:
gridPanel = new JPanel();
grid = new GridLayout(0,1);
gridPanel.setLayout(grid);
gridPanel.add(createChildPanel());
and the createChildPanel method:
JComboBox columnACB = new JComboBox();
columnACB.addItemListener(this);
thanks for the solution: this is what we used
Component[] comps = gridPanel.getComponents();
for (Component comp : comps) {
if (comp instanceof JPanel) {
JPanel panel = (JPanel) comp;
Component[] comps1 = panel.getComponents();
for (Component comp1 : comps1) {
if (comp1 instanceof JComboBox)
{
JComboBox combp = (JComboBox) comp1;
String colA = combp.getSelectedItem().toString();
System.out.println("colA"+colA);
}
else if (comp1 instanceof JTextField)
{
JTextField combp = (JTextField) comp1;
String colA = combp.getText();
System.out.println("colA"+colA);
}
}
}
}