src/share/classes/javax/swing/DefaultCellEditor.java

Print this page




 114                 else if (value instanceof String) {
 115                     selected = value.equals("true");
 116                 }
 117                 checkBox.setSelected(selected);
 118             }
 119 
 120             public Object getCellEditorValue() {
 121                 return Boolean.valueOf(checkBox.isSelected());
 122             }
 123         };
 124         checkBox.addActionListener(delegate);
 125         checkBox.setRequestFocusEnabled(false);
 126     }
 127 
 128     /**
 129      * Constructs a <code>DefaultCellEditor</code> object that uses a
 130      * combo box.
 131      *
 132      * @param comboBox  a <code>JComboBox</code> object
 133      */
 134     public DefaultCellEditor(final JComboBox comboBox) {
 135         editorComponent = comboBox;
 136         comboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
 137         delegate = new EditorDelegate() {
 138             public void setValue(Object value) {
 139                 comboBox.setSelectedItem(value);
 140             }
 141 
 142             public Object getCellEditorValue() {
 143                 return comboBox.getSelectedItem();
 144             }
 145 
 146             public boolean shouldSelectCell(EventObject anEvent) {
 147                 if (anEvent instanceof MouseEvent) {
 148                     MouseEvent e = (MouseEvent)anEvent;
 149                     return e.getID() != MouseEvent.MOUSE_DRAGGED;
 150                 }
 151                 return true;
 152             }
 153             public boolean stopCellEditing() {
 154                 if (comboBox.isEditable()) {




 114                 else if (value instanceof String) {
 115                     selected = value.equals("true");
 116                 }
 117                 checkBox.setSelected(selected);
 118             }
 119 
 120             public Object getCellEditorValue() {
 121                 return Boolean.valueOf(checkBox.isSelected());
 122             }
 123         };
 124         checkBox.addActionListener(delegate);
 125         checkBox.setRequestFocusEnabled(false);
 126     }
 127 
 128     /**
 129      * Constructs a <code>DefaultCellEditor</code> object that uses a
 130      * combo box.
 131      *
 132      * @param comboBox  a <code>JComboBox</code> object
 133      */
 134     public DefaultCellEditor(final JComboBox<?> comboBox) {
 135         editorComponent = comboBox;
 136         comboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
 137         delegate = new EditorDelegate() {
 138             public void setValue(Object value) {
 139                 comboBox.setSelectedItem(value);
 140             }
 141 
 142             public Object getCellEditorValue() {
 143                 return comboBox.getSelectedItem();
 144             }
 145 
 146             public boolean shouldSelectCell(EventObject anEvent) {
 147                 if (anEvent instanceof MouseEvent) {
 148                     MouseEvent e = (MouseEvent)anEvent;
 149                     return e.getID() != MouseEvent.MOUSE_DRAGGED;
 150                 }
 151                 return true;
 152             }
 153             public boolean stopCellEditing() {
 154                 if (comboBox.isEditable()) {