home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 January / PCO0198.ISO / 1&1 / java.z / java_301 / java / awt / Window.class (.txt) < prev   
Encoding:
Java Class File  |  1996-10-20  |  2.4 KB  |  86 lines

  1. package java.awt;
  2.  
  3. import java.awt.peer.WindowPeer;
  4.  
  5. public class Window extends Container {
  6.    String warningString;
  7.  
  8.    Window() {
  9.       SecurityManager sm = System.getSecurityManager();
  10.       if (sm != null && !sm.checkTopLevelWindow(this)) {
  11.          this.warningString = System.getProperty("awt.appletWarning", "Warning: Applet Window");
  12.       }
  13.  
  14.    }
  15.  
  16.    public Window(Frame parent) {
  17.       SecurityManager sm = System.getSecurityManager();
  18.       if (sm != null && !sm.checkTopLevelWindow(this)) {
  19.          this.warningString = System.getProperty("awt.appletWarning", "Warning: Applet Window");
  20.       }
  21.  
  22.       super.parent = parent;
  23.       super.visible = false;
  24.       ((Container)this).setLayout(new BorderLayout());
  25.    }
  26.  
  27.    public synchronized void addNotify() {
  28.       if (super.peer == null) {
  29.          super.peer = this.getToolkit().createWindow(this);
  30.       }
  31.  
  32.       super.addNotify();
  33.    }
  34.  
  35.    public synchronized void pack() {
  36.       if (super.peer == null) {
  37.          this.addNotify();
  38.       }
  39.  
  40.       ((Component)this).resize(((Container)this).preferredSize());
  41.       ((Container)this).validate();
  42.    }
  43.  
  44.    public synchronized void show() {
  45.       if (super.peer == null) {
  46.          this.addNotify();
  47.       }
  48.  
  49.       ((Container)this).validate();
  50.       if (super.visible) {
  51.          this.toFront();
  52.       } else {
  53.          super.show();
  54.       }
  55.    }
  56.  
  57.    public synchronized void dispose() {
  58.       ((Component)this).hide();
  59.       ((Container)this).removeNotify();
  60.    }
  61.  
  62.    public void toFront() {
  63.       WindowPeer peer = (WindowPeer)super.peer;
  64.       if (peer != null) {
  65.          peer.toFront();
  66.       }
  67.  
  68.    }
  69.  
  70.    public void toBack() {
  71.       WindowPeer peer = (WindowPeer)super.peer;
  72.       if (peer != null) {
  73.          peer.toBack();
  74.       }
  75.  
  76.    }
  77.  
  78.    public Toolkit getToolkit() {
  79.       return Toolkit.getDefaultToolkit();
  80.    }
  81.  
  82.    public final String getWarningString() {
  83.       return this.warningString;
  84.    }
  85. }
  86.