Browse Source

ToggleButtonList: Update ui of renderers in updateUI

Closes #250
jawt-dll
weisj 3 years ago
parent
commit
8775cbc482
No known key found for this signature in database
GPG Key ID: 31124CB75461DA2A
  1. 19
      core/src/main/java/com/github/weisj/darklaf/components/togglebuttonlist/JToggleButtonList.java

19
core/src/main/java/com/github/weisj/darklaf/components/togglebuttonlist/JToggleButtonList.java

@ -89,22 +89,33 @@ public class JToggleButtonList extends JList<JToggleButton> {
}
public void addToggleButton(final int index, final JToggleButton item) {
gettogglebuttonModel().add(index, item);
getToggleButtonModel().add(index, item);
}
public boolean isSelected(final int index) {
return gettogglebuttonModel().get(index).isSelected();
return getToggleButtonModel().get(index).isSelected();
}
public void setSelected(final int index, final boolean selected) {
gettogglebuttonModel().get(index).setSelected(selected);
getToggleButtonModel().get(index).setSelected(selected);
repaint(getCellBounds(index, index));
}
private DefaultListModel<JToggleButton> gettogglebuttonModel() {
private DefaultListModel<JToggleButton> getToggleButtonModel() {
return ((DefaultListModel<JToggleButton>) getModel());
}
@Override
public void updateUI() {
super.updateUI();
if (getModel() instanceof DefaultListModel) {
DefaultListModel<JToggleButton> model = getToggleButtonModel();
for (int i = 0; i < model.getSize(); i++) {
model.get(i).updateUI();
}
}
}
/**
* Gets all the indices that are checked.
*

Loading…
Cancel
Save