01: package com.jidesoft.swing;
02:
03: import javax.swing.*;
04:
05: public class CheckBoxListSelectionModel extends
06: DefaultListSelectionModel {
07: private ListModel _model;
08:
09: public CheckBoxListSelectionModel() {
10: setSelectionMode(MULTIPLE_INTERVAL_SELECTION);
11: }
12:
13: public CheckBoxListSelectionModel(ListModel model) {
14: _model = model;
15: setSelectionMode(MULTIPLE_INTERVAL_SELECTION);
16: }
17:
18: public ListModel getModel() {
19: return _model;
20: }
21:
22: public void setModel(ListModel model) {
23: int oldLength = 0;
24: int newLength = 0;
25: if (_model != null) {
26: oldLength = _model.getSize();
27: }
28: _model = model;
29: if (_model != null) {
30: newLength = _model.getSize();
31: }
32: if (oldLength > newLength) {
33: removeIndexInterval(newLength, oldLength);
34: }
35: }
36: }
|