📄 checkboxeditor.java
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package mymp3.pp;import java.awt.Component;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util.EventObject;import javax.swing.JCheckBox;import javax.swing.JTable;import javax.swing.event.CellEditorListener;import javax.swing.table.TableCellEditor;/** * * @author huliqing */public class CheckBoxEditor extends JCheckBox implements TableCellEditor{ public CheckBoxEditor() { super(); addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { fireEditingStopped(); } }); } public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { setForeground(table.getSelectionForeground()); setBackground(table.getSelectionBackground()); setSelected((Boolean)value); return this; } public Object getCellEditorValue() { return this.isSelected(); } public boolean isCellEditable(EventObject anEvent) { return true; } public boolean shouldSelectCell(EventObject anEvent) { return true; } public boolean stopCellEditing() { fireEditingStopped(); return true; } public void cancelCellEditing() { fireEditingStopped(); } public void addCellEditorListener(CellEditorListener l) { this.listenerList.add(CellEditorListener.class, l); } public void removeCellEditorListener(CellEditorListener l) { this.listenerList.remove(CellEditorListener.class, l); } protected void fireEditingStopped() { CellEditorListener list; Object[] lists = listenerList.getListenerList(); for (int i = 0; i < lists.length; i++) { if (lists[i] == CellEditorListener.class) { list = (CellEditorListener) lists[i + 1]; list.editingStopped(changeEvent); } } } protected void fireEditingCanceled() { fireEditingStopped(); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -