/[classpath]/classpath/javax/swing/JSplitPane.java
ViewVC logotype

Diff of /classpath/javax/swing/JSplitPane.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4.2.3 by gnu_andrew, Wed Nov 2 00:43:47 2005 UTC revision 1.4.2.4 by gnu_andrew, Sun Nov 27 21:00:37 2005 UTC
# Line 170  public class JSplitPane extends JCompone Line 170  public class JSplitPane extends JCompone
170    public static final int HORIZONTAL_SPLIT = 1;    public static final int HORIZONTAL_SPLIT = 1;
171    
172    /** The property fired when the last divider location property changes. */    /** The property fired when the last divider location property changes. */
173    public static final String LAST_DIVIDER_LOCATION_PROPERTY = "lastDividerLocation";    public static final String LAST_DIVIDER_LOCATION_PROPERTY =
174        "lastDividerLocation";
175    
176    /** The constraints string used to add components to the left. */    /** The constraints string used to add components to the left. */
177    public static final String LEFT = "left";    public static final String LEFT = "left";
178    
179    /** The property fired when the one touch expandable property changes. */    /** The property fired when the one touch expandable property changes. */
180    public static final String ONE_TOUCH_EXPANDABLE_PROPERTY = "oneTouchExpandable";    public static final String ONE_TOUCH_EXPANDABLE_PROPERTY =
181        "oneTouchExpandable";
182    
183    /** The property fired when the orientation property changes. */    /** The property fired when the orientation property changes. */
184    public static final String ORIENTATION_PROPERTY = "orientation";    public static final String ORIENTATION_PROPERTY = "orientation";
# Line 199  public class JSplitPane extends JCompone Line 201  public class JSplitPane extends JCompone
201    /** Whether the JSplitPane uses one touch expandable buttons. */    /** Whether the JSplitPane uses one touch expandable buttons. */
202    protected boolean oneTouchExpandable = false;    protected boolean oneTouchExpandable = false;
203    
204    // This is the master dividerSize variable and sets the BasicSplitPaneDivider one accordingly    // This is the master dividerSize variable and sets the
205      // BasicSplitPaneDivider one accordingly
206    
207    /** The size of the divider. */    /** The size of the divider. */
208    protected int dividerSize = 10;    protected int dividerSize = 10;
# Line 286  public class JSplitPane extends JCompone Line 289  public class JSplitPane extends JCompone
289     */     */
290    public JSplitPane()    public JSplitPane()
291    {    {
292      this(HORIZONTAL_SPLIT, false, null, null);      this(HORIZONTAL_SPLIT, false, new JButton("left button"),
293             new JButton("right button"));
294    }    }
295    
296    /**    /**
# Line 300  public class JSplitPane extends JCompone Line 304  public class JSplitPane extends JCompone
304     * @param constraints The constraints string to use.     * @param constraints The constraints string to use.
305     * @param index Where to place to component in the list of components.     * @param index Where to place to component in the list of components.
306     *     *
307     * @throws IllegalArgumentException When the constraints is not a known identifier.     * @throws IllegalArgumentException When the constraints is not a known
308       * identifier.
309     */     */
310    protected void addImpl(Component comp, Object constraints, int index)    protected void addImpl(Component comp, Object constraints, int index)
311    {    {
# Line 310  public class JSplitPane extends JCompone Line 315  public class JSplitPane extends JCompone
315      int place;      int place;
316      if (constraints == null)      if (constraints == null)
317        {        {
318          if (leftComponent == null)          if (leftComponent == null)
319            constraints = LEFT;            constraints = LEFT;
320          else if (rightComponent == null)          else if (rightComponent == null)
321            constraints = RIGHT;            constraints = RIGHT;
322        }        }
323    
324      if (constraints instanceof String)      if (constraints instanceof String)
325        {        {
326          String placement = (String) constraints;          String placement = (String) constraints;
327    
328          if (placement.equals(BOTTOM) || placement.equals(RIGHT))          if (placement.equals(BOTTOM) || placement.equals(RIGHT))
329            {            {
330              if (rightComponent != null)              if (rightComponent != null)
331                  remove(rightComponent);                remove(rightComponent);
332              rightComponent = comp;              rightComponent = comp;
333            }            }
334          else if (placement.equals(LEFT) || placement.equals(TOP))          else if (placement.equals(LEFT) || placement.equals(TOP))
335            {            {
336              if (leftComponent != null)              if (leftComponent != null)
337                remove(leftComponent);                remove(leftComponent);
338              leftComponent = comp;              leftComponent = comp;
339            }            }
340          else if (placement.equals(DIVIDER))          else if (placement.equals(DIVIDER))
341            constraints = null;            constraints = null;
342          else          else
343            throw new IllegalArgumentException("Constraints is not a known identifier.");            throw new
344                IllegalArgumentException("Constraints is not a known identifier.");
345    
346          super.addImpl(comp, constraints, index);          super.addImpl(comp, constraints, index);
347        }        }
348      invalidate();      invalidate();
349      layout();      layout();
# Line 614  public class JSplitPane extends JCompone Line 620  public class JSplitPane extends JCompone
620    {    {
621      if (newContinuousLayout != continuousLayout)      if (newContinuousLayout != continuousLayout)
622        {        {
623          boolean oldValue = continuousLayout;          boolean oldValue = continuousLayout;
624          continuousLayout = newContinuousLayout;          continuousLayout = newContinuousLayout;
625          firePropertyChange(CONTINUOUS_LAYOUT_PROPERTY, oldValue,          firePropertyChange(CONTINUOUS_LAYOUT_PROPERTY, oldValue,
626                             continuousLayout);                             continuousLayout);
627        }        }
628    }    }
629    
# Line 634  public class JSplitPane extends JCompone Line 640  public class JSplitPane extends JCompone
640    public void setDividerLocation(double proportionalLocation)    public void setDividerLocation(double proportionalLocation)
641    {    {
642      if (proportionalLocation > 1 || proportionalLocation < 0)      if (proportionalLocation > 1 || proportionalLocation < 0)
643        throw new IllegalArgumentException("proportion has to be between 0 and 1.");        throw new IllegalArgumentException
644            ("proportion has to be between 0 and 1.");
645    
646      int max = (orientation == HORIZONTAL_SPLIT) ? getWidth() : getHeight();      int max = (orientation == HORIZONTAL_SPLIT) ? getWidth() : getHeight();
647      setDividerLocation((int) (proportionalLocation * max));      setDividerLocation((int) (proportionalLocation * max));
# Line 649  public class JSplitPane extends JCompone Line 656  public class JSplitPane extends JCompone
656    {    {
657      if (ui != null && location != getDividerLocation())      if (ui != null && location != getDividerLocation())
658        {        {
659          int oldLocation = getDividerLocation();          int oldLocation = getDividerLocation();
660          ((SplitPaneUI) ui).setDividerLocation(this, location);          ((SplitPaneUI) ui).setDividerLocation(this, location);
661          firePropertyChange(DIVIDER_LOCATION_PROPERTY, oldLocation, location);          firePropertyChange(DIVIDER_LOCATION_PROPERTY, oldLocation, location);
662        }        }
663    }    }
664    
# Line 664  public class JSplitPane extends JCompone Line 671  public class JSplitPane extends JCompone
671    {    {
672      if (newSize != dividerSize)      if (newSize != dividerSize)
673        {        {
674          int oldSize = dividerSize;          int oldSize = dividerSize;
675          dividerSize = newSize;          dividerSize = newSize;
676          firePropertyChange(DIVIDER_SIZE_PROPERTY, oldSize, dividerSize);          firePropertyChange(DIVIDER_SIZE_PROPERTY, oldSize, dividerSize);
677        }        }
678    }    }
679    
# Line 683  public class JSplitPane extends JCompone Line 690  public class JSplitPane extends JCompone
690    {    {
691      if (newLastLocation != lastDividerLocation)      if (newLastLocation != lastDividerLocation)
692        {        {
693          int oldValue = lastDividerLocation;          int oldValue = lastDividerLocation;
694          lastDividerLocation = newLastLocation;          lastDividerLocation = newLastLocation;
695          firePropertyChange(LAST_DIVIDER_LOCATION_PROPERTY, oldValue,          firePropertyChange(LAST_DIVIDER_LOCATION_PROPERTY, oldValue,
696                             lastDividerLocation);                             lastDividerLocation);
697        }        }
698    }    }
699    
# Line 696  public class JSplitPane extends JCompone Line 703  public class JSplitPane extends JCompone
703     * @param comp The left component.     * @param comp The left component.
704     */     */
705    public void setLeftComponent(Component comp)    public void setLeftComponent(Component comp)
706    {    {    
707      if (comp != null)      if (comp != null)
708        add(comp, LEFT);        add(comp, LEFT);
709      else      else
710        add(new JButton("left button"), LEFT);        remove (leftComponent);
711    }    }
712    
713    /**    /**
# Line 715  public class JSplitPane extends JCompone Line 722  public class JSplitPane extends JCompone
722    {    {
723      if (newValue != oneTouchExpandable)      if (newValue != oneTouchExpandable)
724        {        {
725          boolean oldValue = oneTouchExpandable;          boolean oldValue = oneTouchExpandable;
726          oneTouchExpandable = newValue;          oneTouchExpandable = newValue;
727          firePropertyChange(ONE_TOUCH_EXPANDABLE_PROPERTY, oldValue,          firePropertyChange(ONE_TOUCH_EXPANDABLE_PROPERTY, oldValue,
728                             oneTouchExpandable);                             oneTouchExpandable);
729        }        }
730    }    }
731    
# Line 732  public class JSplitPane extends JCompone Line 739  public class JSplitPane extends JCompone
739    public void setOrientation(int orientation)    public void setOrientation(int orientation)
740    {    {
741      if (orientation != HORIZONTAL_SPLIT && orientation != VERTICAL_SPLIT)      if (orientation != HORIZONTAL_SPLIT && orientation != VERTICAL_SPLIT)
742        throw new IllegalArgumentException("orientation must be one of VERTICAL_SPLIT, HORIZONTAL_SPLIT");        throw new IllegalArgumentException
743            ("orientation must be one of VERTICAL_SPLIT, HORIZONTAL_SPLIT");
744      if (orientation != this.orientation)      if (orientation != this.orientation)
745        {        {
746          int oldOrientation = this.orientation;          int oldOrientation = this.orientation;
747          this.orientation = orientation;          this.orientation = orientation;
748          firePropertyChange(ORIENTATION_PROPERTY, oldOrientation,          firePropertyChange(ORIENTATION_PROPERTY, oldOrientation,
749                             this.orientation);                             this.orientation);
750        }        }
751    }    }
752    
# Line 766  public class JSplitPane extends JCompone Line 774  public class JSplitPane extends JCompone
774      if (comp != null)      if (comp != null)
775        add(comp, RIGHT);        add(comp, RIGHT);
776      else      else
777          add(new JButton("right button"), RIGHT);        remove (rightComponent);
778    }    }
779    
780    /**    /**

Legend:
Removed from v.1.4.2.3  
changed lines
  Added in v.1.4.2.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26