📄 undoablejcheckbox.java
字号:
import javax.swing.*;import java.awt.event.*;import javax.swing.event.*;import javax.swing.undo.*;public class UndoableJCheckBox extends JCheckBox{/* The UndoableJCheckBox class uses an UndoableEditSupport object *//* to provide an undoable capability to a JCheckBox. */ private UndoableEditSupport undoSupport;/* The constructor calls the JCheckBox constructor and then *//* initializes the UndoableEditSupport object. The event source *//* is set to be the UndoableJCheckBox object. */ public UndoableJCheckBox(String title) { super(title); undoSupport = new UndoableEditSupport(this); }/* The UndoableEditSupport object is used to implement the methods *//* to add or remove an UndoableEditListener from the UndoableJCheckBox. */ public void addUndoableEditListener(UndoableEditListener listener) { undoSupport.addUndoableEditListener(listener); } public void removeUndoableEditListener(UndoableEditListener listener) { undoSupport.removeUndoableEditListener(listener); }/* The fireActionPerformed() method is overridden so that when the mouse *//* is pressed over the UndoableJCheckBox, an UndoableJCheckBoxEdit object *//* is created and sent to any registered UndoableEditListeners. */ protected void fireActionPerformed(ActionEvent event) { super.fireActionPerformed(event); undoSupport.postEdit(new UndoableJCheckBoxEdit(this)); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -