I have a problem with the JList. Whenever i remove items from it, the list does not update it's appearance so items remain there and become uncheckable.
Here is code:
DefaultListModel listModel = new DefaultListModel();
JList figureListBox = new JList(listModel);
figureListBox.setBounds(5, 20, 240, 300);
figureListBox.setBackground(Color.WHITE);
figureListBox.setBorder(BorderFactory.createLineBorder(Color.BLACK));
figureListBox.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
figureListBox.setLayoutOrientation(JList.VERTICAL);
figureListBox.setVisibleRowCount(10);
JButton deleteFigureButton = new JButton("Delete");
deleteFigureButton.setBounds(5, 305, 240, 25);
deleteFigureButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
if(currentFigure != -1) {
listModel.remove(currentFigure);
currentFigure = -1;
}
}
});`
Repaint and revalidate doesn't work, as well as updateUI()