radiobuttoncelleditor.java
来自「一个类似QQ的在线通讯聊天软件原码,适合初学者参考学习。」· Java 代码 · 共 64 行
JAVA
64 行
package openicq.gui;import java.awt.Component;import java.awt.event.ItemEvent;import java.awt.event.ItemListener;import javax.swing.*;/** * The <code>RadioButtonCellEditor</code> class is a custom custom cell editor * for radio buttons. * @author Hansgeorg Schwibbe * @copyright 2004 */class RadioButtonCellEditor extends DefaultCellEditor implements ItemListener{ private JRadioButton radioButton; /** * Initializes a new instance of the class <code>RadioButtonCellEditor</code>. * @param checkBox the check box */ public RadioButtonCellEditor(JCheckBox checkBox) { super(checkBox); } /** * (non-Javadoc) * @see javax.swing.DefaultCellEditor#getTableCellEditorComponent(javax.swing.JTable, * java.lang.Object, boolean, int, int) */ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { if (value instanceof JRadioButton) { radioButton = (JRadioButton) value; radioButton.addItemListener(this); return radioButton; } return new JLabel(String.valueOf(value)); } /** * (non-Javadoc) * @see javax.swing.DefaultCellEditor#getCellEditorValue() */ public Object getCellEditorValue() { radioButton.removeItemListener(this); return radioButton; } /** * (non-Javadoc) * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent) */ public void itemStateChanged(ItemEvent e) { super.fireEditingStopped(); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?