KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jimm > datavision > gui > cmd > SectionResizeCommand


1 package jimm.datavision.gui.cmd;
2 import jimm.datavision.gui.SectionWidget;
3 import jimm.util.I18N;
4
5 /**
6  * Mainly used by other commands to remember a section's old size
7  * and restore it on an undo.
8  *
9  * @author Jim Menard, <a HREF="mailto:jimm@io.com">jimm@io.com</a>
10  */

11 public class SectionResizeCommand extends CommandAdapter {
12
13 protected SectionWidget sw;
14 protected int oldSectionHeight;
15 protected int sectionHeightDelta;
16
17 public SectionResizeCommand(SectionWidget sw)
18 {
19     super(I18N.get("SectionResizeCommand.name"));
20     this.sw = sw;
21     oldSectionHeight = sw.getHeight();
22 }
23
24 public void perform() {
25     sectionHeightDelta = sw.getHeight() - oldSectionHeight;
26 }
27
28 public void undo() {
29     sw.growBy(-sectionHeightDelta);
30 }
31
32 public void redo() {
33     sw.growBy(sectionHeightDelta);
34 }
35
36 }
37
Popular Tags