KickJava   Java API By Example, From Geeks To Geeks.

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


1 package jimm.datavision.gui.cmd;
2 import jimm.datavision.field.Field;
3 import jimm.datavision.field.Rectangle;
4 import jimm.datavision.gui.FieldWidget;
5 import jimm.util.I18N;
6
7 /**
8  * Aligns a single field with another.
9  *
10  * @author Jim Menard, <a HREF="mailto:jimm@io.com">jimm@io.com</a>
11  */

12 public class FieldAlignCommand extends CommandAdapter {
13
14 protected FieldWidget fw;
15 protected int which;
16 protected Field prototype;
17 protected Rectangle origBounds;
18
19 public FieldAlignCommand(FieldWidget fw, int which, Field prototype) {
20     super(I18N.get("FieldAlignCommand.name"));
21
22     this.fw = fw;
23     this.which = which;
24     this.prototype = prototype;
25     origBounds = new Rectangle(fw.getField().getBounds()); // Make a copy
26
}
27
28 public void perform() {
29     fw.align(which, prototype);
30 }
31
32 public void undo() {
33     fw.getField().getBounds().setBounds(origBounds);
34 }
35
36 }
37
Popular Tags