📄 dragundoableedit.java
字号:
package com.sunking.tp.undoredo;
import javax.swing.undo.AbstractUndoableEdit;
import com.sunking.tp.framework.*;
import com.sunking.tp.util.*;
import javax.swing.undo.*;
import java.awt.*;
/**
*
* <p>Title: DragUndoableEdit</p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author <a href="mailto:sunkingxie@hotmail.com">SunKing</a>
* @version 1.0
*/
public class DragUndoableEdit extends AbstractUndoableEdit {
JTPComponent com[];
Desktop desk;
Rectangle oldRec[];
public DragUndoableEdit(Desktop desk, JTPComponent[] com) {
this.com = com;
this.desk = desk;
oldRec = getBounds();
}
Rectangle[] getBounds() {
Rectangle rec[] = new Rectangle[com.length];
for (int index = 0; index < com.length; index++) {
Component c = ( (Component) com[index]);
rec[index] = c.getBounds();
}
return rec;
}
public String getUndoPresentationName() {
return JTPUtil.getString("Undo_Drag");
}
public String getRedoPresentationName() {
return JTPUtil.getString("Redo_Drag");
}
public void undo() throws CannotUndoException {
super.undo();
Rectangle newRec[] = getBounds();
for (int index = 0; index < com.length; index++) {
Component c = ( (Component) com[index]);
c.setBounds(oldRec[index]);
}
oldRec = newRec;
desk.fireAssoicatorChanged();
}
public void redo() throws CannotRedoException {
super.redo();
Rectangle newRec[] = getBounds();
for (int index = 0; index < com.length; index++) {
Component c = ( (Component) com[index]);
c.setBounds(oldRec[index]);
}
oldRec = newRec;
desk.fireAssoicatorChanged();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -