home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 March / pcp161a.iso / handson / files / copyjava.exe / com / sun / java / swing / JWindow.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-02-26  |  3.3 KB  |  119 lines

  1. package com.sun.java.swing;
  2.  
  3. import com.sun.java.accessibility.Accessible;
  4. import com.sun.java.accessibility.AccessibleContext;
  5. import java.awt.Component;
  6. import java.awt.Container;
  7. import java.awt.Frame;
  8. import java.awt.LayoutManager;
  9. import java.awt.Window;
  10.  
  11. public class JWindow extends Window implements Accessible, RootPaneContainer {
  12.    protected JRootPane rootPane;
  13.    protected boolean rootPaneCheckingEnabled;
  14.    protected AccessibleContext accessibleContext;
  15.  
  16.    public JWindow() {
  17.       this((Frame)null);
  18.    }
  19.  
  20.    public JWindow(Frame var1) {
  21.       super(var1 == null ? SwingUtilities.getSharedOwnerFrame() : var1);
  22.       this.rootPaneCheckingEnabled = false;
  23.       this.windowInit();
  24.    }
  25.  
  26.    protected void windowInit() {
  27.       this.setRootPane(this.createRootPane());
  28.       this.setRootPaneCheckingEnabled(true);
  29.    }
  30.  
  31.    protected JRootPane createRootPane() {
  32.       return new JRootPane();
  33.    }
  34.  
  35.    protected boolean isRootPaneCheckingEnabled() {
  36.       return this.rootPaneCheckingEnabled;
  37.    }
  38.  
  39.    protected void setRootPaneCheckingEnabled(boolean var1) {
  40.       this.rootPaneCheckingEnabled = var1;
  41.    }
  42.  
  43.    private Error createRootPaneException(String var1) {
  44.       String var2 = this.getClass().getName();
  45.       return new Error("Do not use " + var2 + "." + var1 + "() use " + var2 + ".getContentPane()." + var1 + "() instead");
  46.    }
  47.  
  48.    protected void addImpl(Component var1, Object var2, int var3) {
  49.       if (this.isRootPaneCheckingEnabled()) {
  50.          throw this.createRootPaneException("add");
  51.       } else {
  52.          super.addImpl(var1, var2, var3);
  53.       }
  54.    }
  55.  
  56.    public void setLayout(LayoutManager var1) {
  57.       if (this.isRootPaneCheckingEnabled()) {
  58.          throw this.createRootPaneException("setLayout");
  59.       } else {
  60.          super.setLayout(var1);
  61.       }
  62.    }
  63.  
  64.    public JRootPane getRootPane() {
  65.       return this.rootPane;
  66.    }
  67.  
  68.    protected void setRootPane(JRootPane var1) {
  69.       if (this.rootPane != null) {
  70.          ((Container)this).remove(this.rootPane);
  71.       }
  72.  
  73.       this.rootPane = var1;
  74.       if (this.rootPane != null) {
  75.          boolean var2 = this.isRootPaneCheckingEnabled();
  76.  
  77.          try {
  78.             this.setRootPaneCheckingEnabled(false);
  79.             ((Container)this).add(this.rootPane, "Center");
  80.          } finally {
  81.             this.setRootPaneCheckingEnabled(var2);
  82.          }
  83.  
  84.       }
  85.    }
  86.  
  87.    public Container getContentPane() {
  88.       return this.getRootPane().getContentPane();
  89.    }
  90.  
  91.    public void setContentPane(Container var1) {
  92.       this.getRootPane().setContentPane(var1);
  93.    }
  94.  
  95.    public JLayeredPane getLayeredPane() {
  96.       return this.getRootPane().getLayeredPane();
  97.    }
  98.  
  99.    public void setLayeredPane(JLayeredPane var1) {
  100.       this.getRootPane().setLayeredPane(var1);
  101.    }
  102.  
  103.    public Component getGlassPane() {
  104.       return this.getRootPane().getGlassPane();
  105.    }
  106.  
  107.    public void setGlassPane(Component var1) {
  108.       this.getRootPane().setGlassPane(var1);
  109.    }
  110.  
  111.    public AccessibleContext getAccessibleContext() {
  112.       if (this.accessibleContext == null) {
  113.          this.accessibleContext = new AccessibleJWindow(this);
  114.       }
  115.  
  116.       return this.accessibleContext;
  117.    }
  118. }
  119.