home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 144 / DPCS0200.iso / Internet / Supanet / system / swing.jar / javax / swing / JFrame.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-11-05  |  5.0 KB  |  188 lines

  1. package javax.swing;
  2.  
  3. import java.awt.AWTEvent;
  4. import java.awt.Component;
  5. import java.awt.Container;
  6. import java.awt.Frame;
  7. import java.awt.Graphics;
  8. import java.awt.LayoutManager;
  9. import java.awt.event.InputEvent;
  10. import java.awt.event.KeyEvent;
  11. import java.awt.event.WindowEvent;
  12. import javax.accessibility.Accessible;
  13. import javax.accessibility.AccessibleContext;
  14.  
  15. public class JFrame extends Frame implements WindowConstants, Accessible, RootPaneContainer {
  16.    private int defaultCloseOperation = 1;
  17.    protected JRootPane rootPane;
  18.    protected boolean rootPaneCheckingEnabled = false;
  19.    protected AccessibleContext accessibleContext = null;
  20.  
  21.    public JFrame() {
  22.       this.frameInit();
  23.    }
  24.  
  25.    public JFrame(String var1) {
  26.       super(var1);
  27.       this.frameInit();
  28.    }
  29.  
  30.    protected void addImpl(Component var1, Object var2, int var3) {
  31.       if (this.isRootPaneCheckingEnabled()) {
  32.          throw this.createRootPaneException("add");
  33.       } else {
  34.          super.addImpl(var1, var2, var3);
  35.       }
  36.    }
  37.  
  38.    protected JRootPane createRootPane() {
  39.       return new JRootPane();
  40.    }
  41.  
  42.    private Error createRootPaneException(String var1) {
  43.       String var2 = this.getClass().getName();
  44.       return new Error("Do not use " + var2 + "." + var1 + "() use " + var2 + ".getContentPane()." + var1 + "() instead");
  45.    }
  46.  
  47.    protected void frameInit() {
  48.       ((Component)this).enableEvents(72L);
  49.       this.setRootPane(this.createRootPane());
  50.       ((Component)this).setBackground(UIManager.getColor("control"));
  51.       this.setRootPaneCheckingEnabled(true);
  52.    }
  53.  
  54.    public AccessibleContext getAccessibleContext() {
  55.       if (this.accessibleContext == null) {
  56.          this.accessibleContext = new AccessibleJFrame(this);
  57.       }
  58.  
  59.       return this.accessibleContext;
  60.    }
  61.  
  62.    public Container getContentPane() {
  63.       return this.getRootPane().getContentPane();
  64.    }
  65.  
  66.    public int getDefaultCloseOperation() {
  67.       return this.defaultCloseOperation;
  68.    }
  69.  
  70.    public Component getGlassPane() {
  71.       return this.getRootPane().getGlassPane();
  72.    }
  73.  
  74.    public JMenuBar getJMenuBar() {
  75.       return this.getRootPane().getMenuBar();
  76.    }
  77.  
  78.    public JLayeredPane getLayeredPane() {
  79.       return this.getRootPane().getLayeredPane();
  80.    }
  81.  
  82.    public JRootPane getRootPane() {
  83.       return this.rootPane;
  84.    }
  85.  
  86.    protected boolean isRootPaneCheckingEnabled() {
  87.       return this.rootPaneCheckingEnabled;
  88.    }
  89.  
  90.    protected String paramString() {
  91.       String var1;
  92.       if (this.defaultCloseOperation == 1) {
  93.          var1 = "HIDE_ON_CLOSE";
  94.       } else if (this.defaultCloseOperation == 2) {
  95.          var1 = "DISPOSE_ON_CLOSE";
  96.       } else if (this.defaultCloseOperation == 0) {
  97.          var1 = "DO_NOTHING_ON_CLOSE";
  98.       } else {
  99.          var1 = "";
  100.       }
  101.  
  102.       String var2 = this.rootPane != null ? this.rootPane.toString() : "";
  103.       String var3 = this.rootPaneCheckingEnabled ? "true" : "false";
  104.       return super.paramString() + ",defaultCloseOperation=" + var1 + ",rootPane=" + var2 + ",rootPaneCheckingEnabled=" + var3;
  105.    }
  106.  
  107.    protected void processKeyEvent(KeyEvent var1) {
  108.       super.processKeyEvent(var1);
  109.       if (!((InputEvent)var1).isConsumed()) {
  110.          JComponent.processKeyBindingsForAllComponents(var1, this, ((AWTEvent)var1).getID() == 401);
  111.       }
  112.  
  113.    }
  114.  
  115.    protected void processWindowEvent(WindowEvent var1) {
  116.       super.processWindowEvent(var1);
  117.       if (((AWTEvent)var1).getID() == 201) {
  118.          switch (this.defaultCloseOperation) {
  119.             case 0:
  120.             default:
  121.                break;
  122.             case 1:
  123.                ((Component)this).setVisible(false);
  124.                break;
  125.             case 2:
  126.                ((Component)this).setVisible(false);
  127.                ((Frame)this).dispose();
  128.          }
  129.       }
  130.  
  131.    }
  132.  
  133.    public void setContentPane(Container var1) {
  134.       this.getRootPane().setContentPane(var1);
  135.    }
  136.  
  137.    public void setDefaultCloseOperation(int var1) {
  138.       this.defaultCloseOperation = var1;
  139.    }
  140.  
  141.    public void setGlassPane(Component var1) {
  142.       this.getRootPane().setGlassPane(var1);
  143.    }
  144.  
  145.    public void setJMenuBar(JMenuBar var1) {
  146.       this.getRootPane().setMenuBar(var1);
  147.    }
  148.  
  149.    public void setLayeredPane(JLayeredPane var1) {
  150.       this.getRootPane().setLayeredPane(var1);
  151.    }
  152.  
  153.    public void setLayout(LayoutManager var1) {
  154.       if (this.isRootPaneCheckingEnabled()) {
  155.          throw this.createRootPaneException("setLayout");
  156.       } else {
  157.          super.setLayout(var1);
  158.       }
  159.    }
  160.  
  161.    protected void setRootPane(JRootPane var1) {
  162.       if (this.rootPane != null) {
  163.          ((Container)this).remove(this.rootPane);
  164.       }
  165.  
  166.       this.rootPane = var1;
  167.       if (this.rootPane != null) {
  168.          boolean var2 = this.isRootPaneCheckingEnabled();
  169.  
  170.          try {
  171.             this.setRootPaneCheckingEnabled(false);
  172.             ((Container)this).add(this.rootPane, "Center");
  173.          } finally {
  174.             this.setRootPaneCheckingEnabled(var2);
  175.          }
  176.       }
  177.  
  178.    }
  179.  
  180.    protected void setRootPaneCheckingEnabled(boolean var1) {
  181.       this.rootPaneCheckingEnabled = var1;
  182.    }
  183.  
  184.    public void update(Graphics var1) {
  185.       ((Container)this).paint(var1);
  186.    }
  187. }
  188.