@@ -46,7 +46,7 @@ public class Permissions extends JFrame {
46
46
static final int BORDER_VERT = 3 ;
47
47
48
48
JScrollPane permissionScroller ;
49
- JList permissionList ;
49
+ JList < JCheckBox > permissionList ;
50
50
JLabel descriptionLabel ;
51
51
// JTextArea descriptionLabel;
52
52
@@ -111,7 +111,7 @@ public void valueChanged(ListSelectionEvent e) {
111
111
permissionList .setBorder (new EmptyBorder (BORDER_VERT , BORDER_HORIZ ,
112
112
BORDER_VERT , BORDER_HORIZ ));
113
113
114
- DefaultListModel model = new DefaultListModel ();
114
+ DefaultListModel < JCheckBox > model = new DefaultListModel < JCheckBox > ();
115
115
permissionList .setModel (model );
116
116
for (String item : title ) {
117
117
model .addElement (new JCheckBox (item ));
@@ -130,7 +130,7 @@ public void keyTyped(KeyEvent e) {
130
130
if (e .getKeyChar () == ' ' ) {
131
131
int index = permissionList .getSelectedIndex ();
132
132
JCheckBox checkbox =
133
- ( JCheckBox ) permissionList .getModel ().getElementAt (index );
133
+ permissionList .getModel ().getElementAt (index );
134
134
checkbox .setSelected (!checkbox .isSelected ());
135
135
permissionList .repaint ();
136
136
}
@@ -497,9 +497,9 @@ public String getMenuTitle() {
497
497
// link. If you run across the original version, please let me know so that
498
498
// the original author can be credited properly. It was from a snippet
499
499
// collection, but it seems to have been picked up so many places with others
500
- // placing their copyright on it, that I haven't been able to determine the
500
+ // placing their copyright on it that I haven't been able to determine the
501
501
// original author. [fry 20100216]
502
- class CheckBoxList extends JList {
502
+ class CheckBoxList extends JList < JCheckBox > {
503
503
protected static Border noFocusBorder = new EmptyBorder (1 , 1 , 1 , 1 );
504
504
int checkboxWidth ;
505
505
@@ -518,7 +518,7 @@ public void mousePressed(MouseEvent e) {
518
518
int index = locationToIndex (e .getPoint ());
519
519
// descriptionLabel.setText(description[index]);
520
520
if (index != -1 ) {
521
- JCheckBox checkbox = ( JCheckBox ) getModel ().getElementAt (index );
521
+ JCheckBox checkbox = getModel ().getElementAt (index );
522
522
//System.out.println("mouse event in list: " + e);
523
523
// System.out.println(checkbox.getSize() + " ... " + checkbox);
524
524
// if (e.getX() < checkbox.getSize().height) {
@@ -534,11 +534,11 @@ public void mousePressed(MouseEvent e) {
534
534
}
535
535
536
536
537
- protected class CellRenderer implements ListCellRenderer {
538
- public Component getListCellRendererComponent (JList list , Object value ,
537
+ protected class CellRenderer implements ListCellRenderer <JCheckBox > {
538
+ public Component getListCellRendererComponent (JList <? extends JCheckBox > list ,
539
+ JCheckBox checkbox ,
539
540
int index , boolean isSelected ,
540
541
boolean cellHasFocus ) {
541
- JCheckBox checkbox = (JCheckBox ) value ;
542
542
// checkbox.setBorder(new EmptyBorder(13, 5, 3, 5)); // trying again
543
543
checkbox .setBackground (isSelected ? getSelectionBackground () : getBackground ());
544
544
checkbox .setForeground (isSelected ? getSelectionForeground () : getForeground ());
@@ -550,5 +550,14 @@ public Component getListCellRendererComponent(JList list, Object value,
550
550
checkbox .setBorder (isSelected ? UIManager .getBorder ("List.focusCellHighlightBorder" ) : noFocusBorder );
551
551
return checkbox ;
552
552
}
553
+
554
+ // @Override
555
+ // public Component getListCellRendererComponent(JList<? extends JCheckBox> list,
556
+ // JCheckBox value, int index,
557
+ // boolean isSelected,
558
+ // boolean cellHasFocus) {
559
+ // // TODO Auto-generated method stub
560
+ // return null;
561
+ // }
553
562
}
554
563
}
0 commit comments