Der bisherige Code für das updaten der ComboBox im TopologiePanel war nicht so schön, habe hier eine Alternative, die speichert auch das zuletzt markierte Element und stellt es ggf. wieder her, verdende das für alle anderen auch so bitte:
// get last selection from combobox
Integer selectedItem = (Integer) sidebar.topolgyPanel.hiddenLayerDropDown.getSelectedItem();
// refresh the combobox: remove all and add then again
// remove all items
sidebar.topolgyPanel.hiddenLayerDropDown.removeAllItems();
// add the items
for (int i = 1; i <= sidebarConfig.getHiddenLayers(); i++) {
sidebar.topolgyPanel.hiddenLayerDropDown.addItem(new Integer(i));
}
// if previous selection was not null, set to old value
if (selectedItem != null) {
// if old value don't exist anymore set to current hidden layer amount,
// otherwise use the previous selected item
if (selectedItem > sidebarConfig.getHiddenLayers()) {
sidebar.topolgyPanel.hiddenLayerDropDown.setSelectedItem(sidebarConfig.getHiddenLayers());
} else {
sidebar.topolgyPanel.hiddenLayerDropDown.setSelectedItem(selectedItem);
}
}
Der bisherige Code für das updaten der ComboBox im TopologiePanel war nicht so schön, habe hier eine Alternative, die speichert auch das zuletzt markierte Element und stellt es ggf. wieder her, verdende das für alle anderen auch so bitte: