home *** CD-ROM | disk | FTP | other *** search
/ S283 Planetary Science &n…he Search for Life DVD 2 / DVD-ROM.iso / install / jre1_3 / lib / rt.jar / javax / swing / JSplitPane.class (.txt) < prev    next >
Encoding:
Java Class File  |  1979-12-31  |  7.1 KB  |  374 lines

  1. package javax.swing;
  2.  
  3. import java.awt.Component;
  4. import java.awt.Container;
  5. import java.awt.Graphics;
  6. import java.awt.LayoutManager;
  7. import java.io.IOException;
  8. import java.io.ObjectOutputStream;
  9. import javax.accessibility.Accessible;
  10. import javax.accessibility.AccessibleContext;
  11. import javax.swing.plaf.SplitPaneUI;
  12.  
  13. public class JSplitPane extends JComponent implements Accessible {
  14.    private static final String uiClassID = "SplitPaneUI";
  15.    public static final int VERTICAL_SPLIT = 0;
  16.    public static final int HORIZONTAL_SPLIT = 1;
  17.    public static final String LEFT = "left";
  18.    public static final String RIGHT = "right";
  19.    public static final String TOP = "top";
  20.    public static final String BOTTOM = "bottom";
  21.    public static final String DIVIDER = "divider";
  22.    public static final String ORIENTATION_PROPERTY = "orientation";
  23.    public static final String CONTINUOUS_LAYOUT_PROPERTY = "continuousLayout";
  24.    public static final String DIVIDER_SIZE_PROPERTY = "dividerSize";
  25.    public static final String ONE_TOUCH_EXPANDABLE_PROPERTY = "oneTouchExpandable";
  26.    public static final String LAST_DIVIDER_LOCATION_PROPERTY = "lastDividerLocation";
  27.    public static final String DIVIDER_LOCATION_PROPERTY = "dividerLocation";
  28.    public static final String RESIZE_WEIGHT_PROPERTY = "resizeWeight";
  29.    protected int orientation;
  30.    protected boolean continuousLayout;
  31.    protected Component leftComponent;
  32.    protected Component rightComponent;
  33.    protected int dividerSize;
  34.    protected boolean oneTouchExpandable;
  35.    protected int lastDividerLocation;
  36.    private double resizeWeight;
  37.    private int dividerLocation;
  38.  
  39.    public JSplitPane() {
  40.       this(1, false, new JButton("left button"), new JButton("right button"));
  41.    }
  42.  
  43.    public JSplitPane(int var1) {
  44.       this(var1, false);
  45.    }
  46.  
  47.    public JSplitPane(int var1, boolean var2) {
  48.       this(var1, var2, (Component)null, (Component)null);
  49.    }
  50.  
  51.    public JSplitPane(int var1, Component var2, Component var3) {
  52.       this(var1, false, var2, var3);
  53.    }
  54.  
  55.    public JSplitPane(int var1, boolean var2, Component var3, Component var4) {
  56.       this.dividerLocation = -1;
  57.       ((Container)this).setLayout((LayoutManager)null);
  58.       ((JComponent)this).setOpaque(true);
  59.       this.orientation = var1;
  60.       if (this.orientation != 1 && this.orientation != 0) {
  61.          throw new IllegalArgumentException("cannot create JSplitPane, orientation must be one of JSplitPane.HORIZONTAL_SPLIT or JSplitPane.VERTICAL_SPLIT");
  62.       } else {
  63.          this.continuousLayout = var2;
  64.          if (var3 != null) {
  65.             this.setLeftComponent(var3);
  66.          }
  67.  
  68.          if (var4 != null) {
  69.             this.setRightComponent(var4);
  70.          }
  71.  
  72.          this.updateUI();
  73.       }
  74.    }
  75.  
  76.    public void setUI(SplitPaneUI var1) {
  77.       if ((SplitPaneUI)super.ui != var1) {
  78.          super.setUI(var1);
  79.          ((JComponent)this).revalidate();
  80.       }
  81.  
  82.    }
  83.  
  84.    public SplitPaneUI getUI() {
  85.       return (SplitPaneUI)super.ui;
  86.    }
  87.  
  88.    public void updateUI() {
  89.       this.setUI((SplitPaneUI)UIManager.getUI(this));
  90.       ((JComponent)this).revalidate();
  91.    }
  92.  
  93.    public String getUIClassID() {
  94.       return "SplitPaneUI";
  95.    }
  96.  
  97.    public void setDividerSize(int var1) {
  98.       int var2 = this.dividerSize;
  99.       if (var2 != var1) {
  100.          this.dividerSize = var1;
  101.          ((JComponent)this).firePropertyChange("dividerSize", var2, var1);
  102.       }
  103.  
  104.    }
  105.  
  106.    public int getDividerSize() {
  107.       return this.dividerSize;
  108.    }
  109.  
  110.    public void setLeftComponent(Component var1) {
  111.       if (var1 == null) {
  112.          if (this.leftComponent != null) {
  113.             this.remove(this.leftComponent);
  114.             this.leftComponent = null;
  115.          }
  116.       } else {
  117.          ((Container)this).add(var1, "left");
  118.       }
  119.  
  120.    }
  121.  
  122.    public Component getLeftComponent() {
  123.       return this.leftComponent;
  124.    }
  125.  
  126.    public void setTopComponent(Component var1) {
  127.       this.setLeftComponent(var1);
  128.    }
  129.  
  130.    public Component getTopComponent() {
  131.       return this.leftComponent;
  132.    }
  133.  
  134.    public void setRightComponent(Component var1) {
  135.       if (var1 == null) {
  136.          if (this.rightComponent != null) {
  137.             this.remove(this.rightComponent);
  138.             this.rightComponent = null;
  139.          }
  140.       } else {
  141.          ((Container)this).add(var1, "right");
  142.       }
  143.  
  144.    }
  145.  
  146.    public Component getRightComponent() {
  147.       return this.rightComponent;
  148.    }
  149.  
  150.    public void setBottomComponent(Component var1) {
  151.       this.setRightComponent(var1);
  152.    }
  153.  
  154.    public Component getBottomComponent() {
  155.       return this.rightComponent;
  156.    }
  157.  
  158.    public void setOneTouchExpandable(boolean var1) {
  159.       boolean var2 = this.oneTouchExpandable;
  160.       this.oneTouchExpandable = var1;
  161.       ((JComponent)this).firePropertyChange("oneTouchExpandable", var2, var1);
  162.       ((Component)this).repaint();
  163.    }
  164.  
  165.    public boolean isOneTouchExpandable() {
  166.       return this.oneTouchExpandable;
  167.    }
  168.  
  169.    public void setLastDividerLocation(int var1) {
  170.       int var2 = this.lastDividerLocation;
  171.       this.lastDividerLocation = var1;
  172.       ((JComponent)this).firePropertyChange("lastDividerLocation", var2, var1);
  173.    }
  174.  
  175.    public int getLastDividerLocation() {
  176.       return this.lastDividerLocation;
  177.    }
  178.  
  179.    public void setOrientation(int var1) {
  180.       if (var1 != 0 && var1 != 1) {
  181.          throw new IllegalArgumentException("JSplitPane: orientation must be one of JSplitPane.VERTICAL_SPLIT or JSplitPane.HORIZONTAL_SPLIT");
  182.       } else {
  183.          int var2 = this.orientation;
  184.          this.orientation = var1;
  185.          ((JComponent)this).firePropertyChange("orientation", var2, var1);
  186.       }
  187.    }
  188.  
  189.    public int getOrientation() {
  190.       return this.orientation;
  191.    }
  192.  
  193.    public void setContinuousLayout(boolean var1) {
  194.       boolean var2 = this.continuousLayout;
  195.       this.continuousLayout = var1;
  196.       ((JComponent)this).firePropertyChange("continuousLayout", var2, var1);
  197.    }
  198.  
  199.    public boolean isContinuousLayout() {
  200.       return this.continuousLayout;
  201.    }
  202.  
  203.    public void setResizeWeight(double var1) {
  204.       if (!(var1 < (double)0.0F) && !(var1 > (double)1.0F)) {
  205.          double var3 = this.resizeWeight;
  206.          this.resizeWeight = var1;
  207.          ((JComponent)this).firePropertyChange("resizeWeight", var3, var1);
  208.       } else {
  209.          throw new IllegalArgumentException("JSplitPane weight must be between 0 and 1");
  210.       }
  211.    }
  212.  
  213.    public double getResizeWeight() {
  214.       return this.resizeWeight;
  215.    }
  216.  
  217.    public void resetToPreferredSizes() {
  218.       SplitPaneUI var1 = this.getUI();
  219.       if (var1 != null) {
  220.          var1.resetToPreferredSizes(this);
  221.       }
  222.  
  223.    }
  224.  
  225.    public void setDividerLocation(double var1) {
  226.       if (!(var1 < (double)0.0F) && !(var1 > (double)1.0F)) {
  227.          if (this.getOrientation() == 0) {
  228.             this.setDividerLocation((int)((double)(((JComponent)this).getHeight() - this.getDividerSize()) * var1));
  229.          } else {
  230.             this.setDividerLocation((int)((double)(((JComponent)this).getWidth() - this.getDividerSize()) * var1));
  231.          }
  232.  
  233.       } else {
  234.          throw new IllegalArgumentException("proportional location must be between 0.0 and 1.0.");
  235.       }
  236.    }
  237.  
  238.    public void setDividerLocation(int var1) {
  239.       int var2 = this.dividerLocation;
  240.       this.dividerLocation = var1;
  241.       SplitPaneUI var3 = this.getUI();
  242.       if (var3 != null) {
  243.          var3.setDividerLocation(this, var1);
  244.       }
  245.  
  246.       ((JComponent)this).firePropertyChange("dividerLocation", var2, var1);
  247.       this.setLastDividerLocation(var2);
  248.    }
  249.  
  250.    public int getDividerLocation() {
  251.       return this.dividerLocation;
  252.    }
  253.  
  254.    public int getMinimumDividerLocation() {
  255.       SplitPaneUI var1 = this.getUI();
  256.       return var1 != null ? var1.getMinimumDividerLocation(this) : -1;
  257.    }
  258.  
  259.    public int getMaximumDividerLocation() {
  260.       SplitPaneUI var1 = this.getUI();
  261.       return var1 != null ? var1.getMaximumDividerLocation(this) : -1;
  262.    }
  263.  
  264.    public void remove(Component var1) {
  265.       if (var1 == this.leftComponent) {
  266.          this.leftComponent = null;
  267.       } else if (var1 == this.rightComponent) {
  268.          this.rightComponent = null;
  269.       }
  270.  
  271.       super.remove(var1);
  272.       ((JComponent)this).revalidate();
  273.       ((Component)this).repaint();
  274.    }
  275.  
  276.    public void remove(int var1) {
  277.       Component var2 = ((Container)this).getComponent(var1);
  278.       if (var2 == this.leftComponent) {
  279.          this.leftComponent = null;
  280.       } else if (var2 == this.rightComponent) {
  281.          this.rightComponent = null;
  282.       }
  283.  
  284.       super.remove(var1);
  285.       ((JComponent)this).revalidate();
  286.       ((Component)this).repaint();
  287.    }
  288.  
  289.    public void removeAll() {
  290.       this.leftComponent = this.rightComponent = null;
  291.       super.removeAll();
  292.       ((JComponent)this).revalidate();
  293.       ((Component)this).repaint();
  294.    }
  295.  
  296.    public boolean isValidateRoot() {
  297.       return true;
  298.    }
  299.  
  300.    protected void addImpl(Component var1, Object var2, int var3) {
  301.       if (var2 != null && !(var2 instanceof String)) {
  302.          throw new IllegalArgumentException("cannot add to layout: constraint must be a string (or null)");
  303.       } else {
  304.          if (var2 == null) {
  305.             if (this.getLeftComponent() == null) {
  306.                var2 = "left";
  307.             } else if (this.getRightComponent() == null) {
  308.                var2 = "right";
  309.             }
  310.          }
  311.  
  312.          if (var2 == null || !var2.equals("left") && !var2.equals("top")) {
  313.             if (var2 != null && (var2.equals("right") || var2.equals("bottom"))) {
  314.                Component var5 = this.getRightComponent();
  315.                if (var5 != null) {
  316.                   this.remove(var5);
  317.                }
  318.  
  319.                this.rightComponent = var1;
  320.                var3 = -1;
  321.             } else if (var2 != null && var2.equals("divider")) {
  322.                var3 = -1;
  323.             }
  324.          } else {
  325.             Component var4 = this.getLeftComponent();
  326.             if (var4 != null) {
  327.                this.remove(var4);
  328.             }
  329.  
  330.             this.leftComponent = var1;
  331.             var3 = -1;
  332.          }
  333.  
  334.          super.addImpl(var1, var2, var3);
  335.          ((JComponent)this).revalidate();
  336.          ((Component)this).repaint();
  337.       }
  338.    }
  339.  
  340.    protected void paintChildren(Graphics var1) {
  341.       super.paintChildren(var1);
  342.       SplitPaneUI var2 = this.getUI();
  343.       if (var2 != null) {
  344.          Graphics var3 = SwingGraphics.createSwingGraphics(var1);
  345.          var2.finishedPaintingChildren(this, var3);
  346.          var3.dispose();
  347.       }
  348.  
  349.    }
  350.  
  351.    private void writeObject(ObjectOutputStream var1) throws IOException {
  352.       var1.defaultWriteObject();
  353.       if (super.ui != null && this.getUIClassID().equals("SplitPaneUI")) {
  354.          super.ui.installUI(this);
  355.       }
  356.  
  357.    }
  358.  
  359.    protected String paramString() {
  360.       String var1 = this.orientation == 1 ? "HORIZONTAL_SPLIT" : "VERTICAL_SPLIT";
  361.       String var2 = this.continuousLayout ? "true" : "false";
  362.       String var3 = this.oneTouchExpandable ? "true" : "false";
  363.       return super.paramString() + ",continuousLayout=" + var2 + ",dividerSize=" + this.dividerSize + ",lastDividerLocation=" + this.lastDividerLocation + ",oneTouchExpandable=" + var3 + ",orientation=" + var1;
  364.    }
  365.  
  366.    public AccessibleContext getAccessibleContext() {
  367.       if (super.accessibleContext == null) {
  368.          super.accessibleContext = new AccessibleJSplitPane(this);
  369.       }
  370.  
  371.       return super.accessibleContext;
  372.    }
  373. }
  374.