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

  1. package javax.swing;
  2.  
  3. import java.awt.Component;
  4. import java.awt.Container;
  5. import java.awt.IllegalComponentStateException;
  6. import java.awt.LayoutManager;
  7. import javax.accessibility.Accessible;
  8. import javax.accessibility.AccessibleContext;
  9.  
  10. public class JRootPane extends JComponent implements Accessible {
  11.    protected JMenuBar menuBar;
  12.    protected Container contentPane;
  13.    protected JLayeredPane layeredPane;
  14.    protected Component glassPane;
  15.    protected JButton defaultButton;
  16.    protected DefaultAction defaultPressAction;
  17.    protected DefaultAction defaultReleaseAction;
  18.  
  19.    public JRootPane() {
  20.       this.setGlassPane(this.createGlassPane());
  21.       this.setLayeredPane(this.createLayeredPane());
  22.       this.setContentPane(this.createContentPane());
  23.       ((Container)this).setLayout(this.createRootLayout());
  24.       ((JComponent)this).setDoubleBuffered(true);
  25.       ((JComponent)this).setBackground(UIManager.getColor("control"));
  26.    }
  27.  
  28.    protected void addImpl(Component var1, Object var2, int var3) {
  29.       super.addImpl(var1, var2, var3);
  30.       if (this.glassPane != null && this.glassPane.getParent() == this && ((Container)this).getComponent(0) != this.glassPane) {
  31.          ((Container)this).add(this.glassPane, 0);
  32.       }
  33.  
  34.    }
  35.  
  36.    public void addNotify() {
  37.       SystemEventQueueUtilities.addRunnableCanvas(this);
  38.       super.addNotify();
  39.       ((Component)this).enableEvents(8L);
  40.    }
  41.  
  42.    protected Container createContentPane() {
  43.       JPanel var1 = new JPanel();
  44.       ((Component)var1).setName(((Component)this).getName() + ".contentPane");
  45.       ((Container)var1).setLayout(new 1());
  46.       return var1;
  47.    }
  48.  
  49.    protected Component createGlassPane() {
  50.       JPanel var1 = new JPanel();
  51.       ((Component)var1).setName(((Component)this).getName() + ".glassPane");
  52.       ((JComponent)var1).setVisible(false);
  53.       ((JPanel)var1).setOpaque(false);
  54.       return var1;
  55.    }
  56.  
  57.    protected JLayeredPane createLayeredPane() {
  58.       JLayeredPane var1 = new JLayeredPane();
  59.       ((Component)var1).setName(((Component)this).getName() + ".layeredPane");
  60.       return var1;
  61.    }
  62.  
  63.    protected LayoutManager createRootLayout() {
  64.       return new RootLayout(this);
  65.    }
  66.  
  67.    public AccessibleContext getAccessibleContext() {
  68.       if (super.accessibleContext == null) {
  69.          super.accessibleContext = new AccessibleJRootPane(this);
  70.       }
  71.  
  72.       return super.accessibleContext;
  73.    }
  74.  
  75.    public Container getContentPane() {
  76.       return this.contentPane;
  77.    }
  78.  
  79.    public JButton getDefaultButton() {
  80.       return this.defaultButton;
  81.    }
  82.  
  83.    public Component getGlassPane() {
  84.       return this.glassPane;
  85.    }
  86.  
  87.    public JMenuBar getJMenuBar() {
  88.       return this.menuBar;
  89.    }
  90.  
  91.    public JLayeredPane getLayeredPane() {
  92.       return this.layeredPane;
  93.    }
  94.  
  95.    /** @deprecated */
  96.    public JMenuBar getMenuBar() {
  97.       return this.menuBar;
  98.    }
  99.  
  100.    public boolean isFocusCycleRoot() {
  101.       return true;
  102.    }
  103.  
  104.    public boolean isValidateRoot() {
  105.       return true;
  106.    }
  107.  
  108.    protected String paramString() {
  109.       return super.paramString();
  110.    }
  111.  
  112.    public void removeNotify() {
  113.       SystemEventQueueUtilities.removeRunnableCanvas(this);
  114.       super.removeNotify();
  115.    }
  116.  
  117.    public void setContentPane(Container var1) {
  118.       if (var1 == null) {
  119.          throw new IllegalComponentStateException("contentPane cannot be set to null.");
  120.       } else {
  121.          if (this.contentPane != null && this.contentPane.getParent() == this.layeredPane) {
  122.             this.layeredPane.remove(this.contentPane);
  123.          }
  124.  
  125.          this.contentPane = var1;
  126.          this.layeredPane.add(this.contentPane, JLayeredPane.FRAME_CONTENT_LAYER);
  127.       }
  128.    }
  129.  
  130.    public void setDefaultButton(JButton var1) {
  131.       JButton var2 = this.defaultButton;
  132.       this.defaultButton = var1;
  133.       if (this.defaultPressAction == null) {
  134.          this.defaultPressAction = new DefaultAction(this, true);
  135.          this.defaultReleaseAction = new DefaultAction(this, false);
  136.          ((JComponent)this).registerKeyboardAction(this.defaultPressAction, KeyStroke.getKeyStroke(10, 0, false), 2);
  137.          ((JComponent)this).registerKeyboardAction(this.defaultReleaseAction, KeyStroke.getKeyStroke(10, 0, true), 2);
  138.       }
  139.  
  140.       if (var2 != var1) {
  141.          this.defaultPressAction.setOwner(var1);
  142.          this.defaultReleaseAction.setOwner(var1);
  143.          if (var2 != null) {
  144.             ((Component)var2).repaint();
  145.          }
  146.  
  147.          if (var1 != null) {
  148.             ((Component)var1).repaint();
  149.          }
  150.       }
  151.  
  152.       ((JComponent)this).firePropertyChange("defaultButton", var2, var1);
  153.    }
  154.  
  155.    public void setGlassPane(Component var1) {
  156.       if (var1 == null) {
  157.          throw new NullPointerException("glassPane cannot be set to null.");
  158.       } else {
  159.          boolean var2 = false;
  160.          if (this.glassPane != null && this.glassPane.getParent() == this) {
  161.             ((Container)this).remove(this.glassPane);
  162.             var2 = this.glassPane.isVisible();
  163.          }
  164.  
  165.          var1.setVisible(var2);
  166.          this.glassPane = var1;
  167.          ((Container)this).add(this.glassPane, 0);
  168.          if (var2) {
  169.             ((Component)this).repaint();
  170.          }
  171.  
  172.       }
  173.    }
  174.  
  175.    public void setJMenuBar(JMenuBar var1) {
  176.       if (this.menuBar != null && this.menuBar.getParent() == this.layeredPane) {
  177.          this.layeredPane.remove(this.menuBar);
  178.       }
  179.  
  180.       this.menuBar = var1;
  181.       if (this.menuBar != null) {
  182.          this.layeredPane.add(this.menuBar, JLayeredPane.FRAME_CONTENT_LAYER);
  183.       }
  184.  
  185.    }
  186.  
  187.    public void setLayeredPane(JLayeredPane var1) {
  188.       if (var1 == null) {
  189.          throw new IllegalComponentStateException("layeredPane cannot be set to null.");
  190.       } else {
  191.          if (this.layeredPane != null && this.layeredPane.getParent() == this) {
  192.             ((Container)this).remove(this.layeredPane);
  193.          }
  194.  
  195.          this.layeredPane = var1;
  196.          ((Container)this).add(this.layeredPane, -1);
  197.       }
  198.    }
  199.  
  200.    /** @deprecated */
  201.    public void setMenuBar(JMenuBar var1) {
  202.       if (this.menuBar != null && this.menuBar.getParent() == this.layeredPane) {
  203.          this.layeredPane.remove(this.menuBar);
  204.       }
  205.  
  206.       this.menuBar = var1;
  207.       if (this.menuBar != null) {
  208.          this.layeredPane.add(this.menuBar, JLayeredPane.FRAME_CONTENT_LAYER);
  209.       }
  210.  
  211.    }
  212. }
  213.