I was wondering how to modify a JList so that clicking any values would not do anything. I have looked at other questions but none have helped.
I solved it by using the following class:
class DisabledItemSelectionModel extends DefaultListSelectionModel {
    @Override
    public void setSelectionInterval(int index0, int index1) {
        super.setSelectionInterval(-1, -1);
    }
}
I instantiated the class here:
console.setSelectionModel(new DisabledItemSelectionModel());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With