Source code: com/trapezium/chisel/gui/WorkspaceEvent.java
1 /*
2 * WorkspaceEvent.java
3 */
4
5 package com.trapezium.chisel.gui;
6
7 import java.awt.event.*;
8 import java.awt.Event;
9 import java.awt.Window;
10 import java.awt.Component;
11 import java.awt.Container;
12
13 /** WorkspaceEvent extends WindowEvent because that's what it really should be,
14 except that WindowEvents only work for Windows which are heavyweight components
15 we'd rather not have to use. WorkspaceEvent works for any component.
16 */
17 public class WorkspaceEvent extends WindowEvent {
18
19 public static final int WINDOW_MAXIMIZED = WINDOW_LAST + 1;
20 public static final int WINDOW_DEMAXIMIZED = WINDOW_LAST + 2;
21
22 static Window dummyWindow = null;
23 static Window getWindow(Component comp) {
24
25 if (dummyWindow == null) {
26 Container parent = comp.getParent();
27 while (parent != null && !(parent instanceof Window)) {
28 parent = parent.getParent();
29 }
30 dummyWindow = (Window) parent;
31 }
32 return dummyWindow;
33 }
34
35 public WorkspaceEvent(Component source, int id) {
36 // construct with a dummy window source
37 super(getWindow(source), id);
38 // now set the source
39 this.source = source;
40 }
41 }