home *** CD-ROM | disk | FTP | other *** search
- package java.awt;
-
- import java.awt.event.InputEvent;
- import java.awt.event.KeyEvent;
- import java.awt.event.WindowEvent;
- import java.awt.event.WindowListener;
- import java.awt.peer.WindowPeer;
- import java.io.IOException;
- import java.io.ObjectInputStream;
- import java.io.ObjectOutputStream;
- import java.util.EventObject;
- import java.util.Locale;
- import sun.awt.im.InputContext;
-
- public class Window extends Container {
- String warningString;
- static final int OPENED = 1;
- int state;
- transient WindowListener windowListener;
- private transient boolean active;
- transient InputContext inputContext;
- private FocusManager focusMgr;
- private static final String base = "win";
- private static int nameCounter;
- private static final long serialVersionUID = 4497834738069338734L;
- private int windowSerializedDataVersion;
-
- Window() {
- this.windowSerializedDataVersion = 1;
- super.name = "win" + nameCounter++;
- SecurityManager var1 = System.getSecurityManager();
- if (var1 != null && !var1.checkTopLevelWindow(this)) {
- this.warningString = System.getProperty("awt.appletWarning", "Warning: Applet Window");
- }
-
- this.focusMgr = new FocusManager(this);
- super.visible = false;
- }
-
- public Window(Frame var1) {
- this();
- if (var1 == null) {
- throw new IllegalArgumentException("null parent frame");
- } else {
- super.parent = var1;
- var1.addOwnedWindow(this);
- ((Container)this).setLayout(new BorderLayout());
- }
- }
-
- public void addNotify() {
- Object var1 = ((Component)this).getTreeLock();
- synchronized(var1){}
-
- try {
- if (super.peer == null) {
- super.peer = this.getToolkit().createWindow(this);
- }
-
- super.addNotify();
- } catch (Throwable var3) {
- throw var3;
- }
-
- }
-
- public void pack() {
- Container var1 = super.parent;
- if (var1 != null && ((Component)var1).getPeer() == null) {
- var1.addNotify();
- }
-
- if (super.peer == null) {
- this.addNotify();
- }
-
- ((Component)this).setSize(((Container)this).getPreferredSize());
- ((Container)this).validate();
- }
-
- public void show() {
- Container var1 = super.parent;
- if (var1 != null && ((Component)var1).getPeer() == null) {
- var1.addNotify();
- }
-
- if (super.peer == null) {
- this.addNotify();
- }
-
- ((Container)this).validate();
- if (super.visible) {
- this.toFront();
- } else {
- super.show();
- }
-
- if ((this.state & 1) == 0) {
- this.postWindowEvent(200);
- this.state |= 1;
- }
-
- }
-
- synchronized void postWindowEvent(int var1) {
- if (this.windowListener != null || (super.eventMask & 64L) != 0L) {
- WindowEvent var2 = new WindowEvent(this, var1);
- Toolkit.getEventQueue().postEvent(var2);
- }
-
- }
-
- public void dispose() {
- Object var1 = ((Component)this).getTreeLock();
- synchronized(var1){}
-
- try {
- if (this.inputContext != null) {
- InputContext var3 = this.inputContext;
- this.inputContext = null;
- var3.dispose();
- }
-
- ((Component)this).hide();
- ((Container)this).removeNotify();
- if (super.parent != null) {
- Frame var6 = (Frame)super.parent;
- var6.removeOwnedWindow(this);
- }
-
- this.postWindowEvent(202);
- } catch (Throwable var5) {
- throw var5;
- }
-
- }
-
- public void toFront() {
- WindowPeer var1 = (WindowPeer)super.peer;
- if (var1 != null) {
- var1.toFront();
- } else {
- this.show();
- }
- }
-
- public void toBack() {
- WindowPeer var1 = (WindowPeer)super.peer;
- if (var1 != null) {
- var1.toBack();
- }
-
- }
-
- public Toolkit getToolkit() {
- return Toolkit.getDefaultToolkit();
- }
-
- public final String getWarningString() {
- return this.warningString;
- }
-
- public Locale getLocale() {
- return super.locale == null ? Locale.getDefault() : super.locale;
- }
-
- synchronized InputContext getInputContext() {
- if (this.inputContext == null) {
- this.inputContext = InputContext.getInstance();
- }
-
- return this.inputContext;
- }
-
- public synchronized void addWindowListener(WindowListener var1) {
- this.windowListener = AWTEventMulticaster.add(this.windowListener, var1);
- super.newEventsOnly = true;
- }
-
- public synchronized void removeWindowListener(WindowListener var1) {
- this.windowListener = AWTEventMulticaster.remove(this.windowListener, var1);
- }
-
- boolean eventEnabled(AWTEvent var1) {
- switch (var1.id) {
- case 200:
- case 201:
- case 202:
- case 203:
- case 204:
- case 205:
- case 206:
- if ((super.eventMask & 64L) == 0L && this.windowListener == null) {
- return false;
- }
-
- return true;
- default:
- return super.eventEnabled(var1);
- }
- }
-
- protected void processEvent(AWTEvent var1) {
- if (var1 instanceof WindowEvent) {
- this.processWindowEvent((WindowEvent)var1);
- } else {
- super.processEvent(var1);
- }
- }
-
- protected void processWindowEvent(WindowEvent var1) {
- if (this.windowListener != null) {
- switch (((AWTEvent)var1).getID()) {
- case 200:
- this.windowListener.windowOpened(var1);
- return;
- case 201:
- this.windowListener.windowClosing(var1);
- return;
- case 202:
- this.windowListener.windowClosed(var1);
- return;
- case 203:
- this.windowListener.windowIconified(var1);
- return;
- case 204:
- this.windowListener.windowDeiconified(var1);
- return;
- case 205:
- this.windowListener.windowActivated(var1);
- return;
- case 206:
- this.windowListener.windowDeactivated(var1);
- return;
- }
- }
-
- }
-
- private boolean handleTabEvent(KeyEvent var1) {
- if (var1.getKeyCode() == 9 && !(((EventObject)var1).getSource() instanceof TextArea)) {
- if ((((InputEvent)var1).getModifiers() & -2) > 0) {
- return false;
- } else {
- int var2 = ((AWTEvent)var1).getID();
- if (var2 != 402 && var2 != 400) {
- return ((InputEvent)var1).isShiftDown() ? this.focusMgr.focusPrevious() : this.focusMgr.focusNext();
- } else {
- return true;
- }
- }
- } else {
- return false;
- }
- }
-
- void preProcessKeyEvent(KeyEvent var1) {
- if (var1.isActionKey() && var1.getKeyCode() == 112 && ((InputEvent)var1).isControlDown() && ((InputEvent)var1).isShiftDown()) {
- ((Container)this).list(System.out, 0);
- }
-
- }
-
- void postProcessKeyEvent(KeyEvent var1) {
- if (this.handleTabEvent(var1)) {
- ((InputEvent)var1).consume();
- }
- }
-
- boolean isActive() {
- return this.active;
- }
-
- void setFocusOwner(Component var1) {
- this.focusMgr.setFocusOwner(var1);
- }
-
- void transferFocus(Component var1) {
- this.nextFocus(var1);
- }
-
- public Component getFocusOwner() {
- return this.active ? this.focusMgr.getFocusOwner() : null;
- }
-
- /** @deprecated */
- void nextFocus(Component var1) {
- this.focusMgr.focusNext(var1);
- }
-
- void dispatchEventImpl(AWTEvent var1) {
- switch (var1.getID()) {
- case 101:
- ((Container)this).invalidate();
- ((Container)this).validate();
- ((Component)this).repaint();
- break;
- case 205:
- this.active = true;
- break;
- case 206:
- this.active = false;
- break;
- case 1004:
- this.setFocusOwner(this);
- }
-
- super.dispatchEventImpl(var1);
- }
-
- /** @deprecated */
- public boolean postEvent(Event var1) {
- if (((Component)this).handleEvent(var1)) {
- var1.consume();
- return true;
- } else {
- return false;
- }
- }
-
- public boolean isShowing() {
- return super.visible;
- }
-
- private void writeObject(ObjectOutputStream var1) throws IOException {
- var1.defaultWriteObject();
- AWTEventMulticaster.save(var1, "windowL", this.windowListener);
- var1.writeObject((Object)null);
- }
-
- private void readObject(ObjectInputStream var1) throws ClassNotFoundException, IOException {
- var1.defaultReadObject();
-
- Object var2;
- while((var2 = var1.readObject()) != null) {
- String var3 = ((String)var2).intern();
- if (var3 == "windowL") {
- this.addWindowListener((WindowListener)var1.readObject());
- } else {
- var1.readObject();
- }
- }
-
- }
- }
-