@@ -46,7 +46,7 @@ public class Permissions extends JFrame {
4646 static final int BORDER_VERT = 3 ;
4747
4848 JScrollPane permissionScroller ;
49- JList permissionList ;
49+ JList < JCheckBox > permissionList ;
5050 JLabel descriptionLabel ;
5151// JTextArea descriptionLabel;
5252
@@ -111,7 +111,7 @@ public void valueChanged(ListSelectionEvent e) {
111111 permissionList .setBorder (new EmptyBorder (BORDER_VERT , BORDER_HORIZ ,
112112 BORDER_VERT , BORDER_HORIZ ));
113113
114- DefaultListModel model = new DefaultListModel ();
114+ DefaultListModel < JCheckBox > model = new DefaultListModel < JCheckBox > ();
115115 permissionList .setModel (model );
116116 for (String item : title ) {
117117 model .addElement (new JCheckBox (item ));
@@ -130,7 +130,7 @@ public void keyTyped(KeyEvent e) {
130130 if (e .getKeyChar () == ' ' ) {
131131 int index = permissionList .getSelectedIndex ();
132132 JCheckBox checkbox =
133- ( JCheckBox ) permissionList .getModel ().getElementAt (index );
133+ permissionList .getModel ().getElementAt (index );
134134 checkbox .setSelected (!checkbox .isSelected ());
135135 permissionList .repaint ();
136136 }
@@ -497,9 +497,9 @@ public String getMenuTitle() {
497497// link. If you run across the original version, please let me know so that
498498// the original author can be credited properly. It was from a snippet
499499// 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
501501// original author. [fry 20100216]
502- class CheckBoxList extends JList {
502+ class CheckBoxList extends JList < JCheckBox > {
503503 protected static Border noFocusBorder = new EmptyBorder (1 , 1 , 1 , 1 );
504504 int checkboxWidth ;
505505
@@ -518,7 +518,7 @@ public void mousePressed(MouseEvent e) {
518518 int index = locationToIndex (e .getPoint ());
519519// descriptionLabel.setText(description[index]);
520520 if (index != -1 ) {
521- JCheckBox checkbox = ( JCheckBox ) getModel ().getElementAt (index );
521+ JCheckBox checkbox = getModel ().getElementAt (index );
522522 //System.out.println("mouse event in list: " + e);
523523// System.out.println(checkbox.getSize() + " ... " + checkbox);
524524// if (e.getX() < checkbox.getSize().height) {
@@ -534,11 +534,11 @@ public void mousePressed(MouseEvent e) {
534534 }
535535
536536
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 ,
539540 int index , boolean isSelected ,
540541 boolean cellHasFocus ) {
541- JCheckBox checkbox = (JCheckBox ) value ;
542542// checkbox.setBorder(new EmptyBorder(13, 5, 3, 5)); // trying again
543543 checkbox .setBackground (isSelected ? getSelectionBackground () : getBackground ());
544544 checkbox .setForeground (isSelected ? getSelectionForeground () : getForeground ());
@@ -550,5 +550,14 @@ public Component getListCellRendererComponent(JList list, Object value,
550550 checkbox .setBorder (isSelected ? UIManager .getBorder ("List.focusCellHighlightBorder" ) : noFocusBorder );
551551 return checkbox ;
552552 }
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+ // }
553562 }
554563}
0 commit comments