Source for javax.swing.JSplitPane

   1: /* JSplitPane.java -- 
   2:    Copyright (C) 2004  Free Software Foundation, Inc.
   3: 
   4: This file is part of GNU Classpath.
   5: 
   6: GNU Classpath is free software; you can redistribute it and/or modify
   7: it under the terms of the GNU General Public License as published by
   8: the Free Software Foundation; either version 2, or (at your option)
   9: any later version.
  10: 
  11: GNU Classpath is distributed in the hope that it will be useful, but
  12: WITHOUT ANY WARRANTY; without even the implied warranty of
  13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14: General Public License for more details.
  15: 
  16: You should have received a copy of the GNU General Public License
  17: along with GNU Classpath; see the file COPYING.  If not, write to the
  18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19: 02110-1301 USA.
  20: 
  21: Linking this library statically or dynamically with other modules is
  22: making a combined work based on this library.  Thus, the terms and
  23: conditions of the GNU General Public License cover the whole
  24: combination.
  25: 
  26: As a special exception, the copyright holders of this library give you
  27: permission to link this library with independent modules to produce an
  28: executable, regardless of the license terms of these independent
  29: modules, and to copy and distribute the resulting executable under
  30: terms of your choice, provided that you also meet, for each linked
  31: independent module, the terms and conditions of the license of that
  32: module.  An independent module is a module which is not derived from
  33: or based on this library.  If you modify this library, you may extend
  34: this exception to your version of the library, but you are not
  35: obligated to do so.  If you do not wish to do so, delete this
  36: exception statement from your version. */
  37: 
  38: 
  39: package javax.swing;
  40: 
  41: import java.awt.Component;
  42: import java.awt.Graphics;
  43: 
  44: import javax.accessibility.Accessible;
  45: import javax.accessibility.AccessibleContext;
  46: import javax.accessibility.AccessibleRole;
  47: import javax.accessibility.AccessibleStateSet;
  48: import javax.accessibility.AccessibleValue;
  49: import javax.swing.plaf.SplitPaneUI;
  50: 
  51: /**
  52:  * This class implements JSplitPane. It is used to divide two components. By
  53:  * dragging the SplitPane's divider, the user can resize the two components.
  54:  * Note that the divider cannot resize a component to smaller than it's
  55:  * minimum size.
  56:  */
  57: public class JSplitPane extends JComponent implements Accessible
  58: {
  59:   /**
  60:    * DOCUMENT ME!
  61:    */
  62:   protected class AccessibleJSplitPane extends JComponent.AccessibleJComponent
  63:     implements AccessibleValue
  64:   {
  65:   private static final long serialVersionUID = -1788116871416305366L;
  66:   
  67:     /**
  68:      * Creates a new AccessibleJSplitPane object.
  69:      *
  70:      * @param value0 DOCUMENT ME!
  71:      */
  72:     protected AccessibleJSplitPane()
  73:     {
  74:     }
  75: 
  76:     /**
  77:      * DOCUMENT ME!
  78:      *
  79:      * @return DOCUMENT ME!
  80:      */
  81:     public AccessibleStateSet getAccessibleStateSet()
  82:     {
  83:       return null;
  84:     }
  85: 
  86:     /**
  87:      * DOCUMENT ME!
  88:      *
  89:      * @return DOCUMENT ME!
  90:      */
  91:     public AccessibleRole getAccessibleRole()
  92:     {
  93:       return null;
  94:     }
  95: 
  96:     /**
  97:      * DOCUMENT ME!
  98:      *
  99:      * @return DOCUMENT ME!
 100:      */
 101:     public AccessibleValue getAccessibleValue()
 102:     {
 103:       return null;
 104:     }
 105: 
 106:     /**
 107:      * DOCUMENT ME!
 108:      *
 109:      * @return DOCUMENT ME!
 110:      */
 111:     public Number getCurrentAccessibleValue()
 112:     {
 113:       return null;
 114:     }
 115: 
 116:     /**
 117:      * DOCUMENT ME!
 118:      *
 119:      * @param value0 DOCUMENT ME!
 120:      *
 121:      * @return DOCUMENT ME!
 122:      */
 123:     public boolean setCurrentAccessibleValue(Number value0)
 124:     {
 125:       return false;
 126:     }
 127: 
 128:     /**
 129:      * DOCUMENT ME!
 130:      *
 131:      * @return DOCUMENT ME!
 132:      */
 133:     public Number getMinimumAccessibleValue()
 134:     {
 135:       return null;
 136:     }
 137: 
 138:     /**
 139:      * DOCUMENT ME!
 140:      *
 141:      * @return DOCUMENT ME!
 142:      */
 143:     public Number getMaximumAccessibleValue()
 144:     {
 145:       return null;
 146:     }
 147:   }
 148: 
 149:   private static final long serialVersionUID = -5634142046175988380L;
 150:   
 151:   /** The constraints string used to add components to the bottom. */
 152:   public static final String BOTTOM = "bottom";
 153: 
 154:   /** The property fired when the continuousLayout property changes. */
 155:   public static final String CONTINUOUS_LAYOUT_PROPERTY = "continuousLayout";
 156: 
 157:   /** The property fired when the divider property changes. */
 158:   public static final String DIVIDER = "divider";
 159: 
 160:   /** The property fired when the divider location property changes. */
 161:   public static final String DIVIDER_LOCATION_PROPERTY = "dividerLocation";
 162: 
 163:   /** The property fired when the divider size property changes. */
 164:   public static final String DIVIDER_SIZE_PROPERTY = "dividerSize";
 165: 
 166:   /**
 167:    * The value of the orientation when the components are split horizontally.
 168:    */
 169:   public static final int HORIZONTAL_SPLIT = 1;
 170: 
 171:   /** The property fired when the last divider location property changes. */
 172:   public static final String LAST_DIVIDER_LOCATION_PROPERTY = "lastDividerLocation";
 173: 
 174:   /** The constraints string used to add components to the left. */
 175:   public static final String LEFT = "left";
 176: 
 177:   /** The property fired when the one touch expandable property changes. */
 178:   public static final String ONE_TOUCH_EXPANDABLE_PROPERTY = "oneTouchExpandable";
 179: 
 180:   /** The property fired when the orientation property changes. */
 181:   public static final String ORIENTATION_PROPERTY = "orientation";
 182: 
 183:   /** The property fired when the resize weight property changes. */
 184:   public static final String RESIZE_WEIGHT_PROPERTY = "resizeWeight";
 185: 
 186:   /** The constraints string used to add components to the right. */
 187:   public static final String RIGHT = "right";
 188: 
 189:   /** The constraints string used to add components to the top. */
 190:   public static final String TOP = "top";
 191: 
 192:   /** The value of the orientation when the components are split vertically. */
 193:   public static final int VERTICAL_SPLIT = 0;
 194: 
 195:   /** Whether the JSplitPane uses continuous layout. */
 196:   protected boolean continuousLayout;
 197: 
 198:   /** Whether the JSplitPane uses one touch expandable buttons. */
 199:   protected boolean oneTouchExpandable = false;
 200: 
 201:   // This is the master dividerSize variable and sets the BasicSplitPaneDivider one accordingly
 202: 
 203:   /** The size of the divider. */
 204:   protected int dividerSize = 10;
 205: 
 206:   /** The last location of the divider given by the UI. */
 207:   protected int lastDividerLocation;
 208: 
 209:   /** The orientation of the JSplitPane. */
 210:   protected int orientation;
 211: 
 212:   /** The component on the top or left. */
 213:   protected Component leftComponent;
 214: 
 215:   /** The component on the right or bottom. */
 216:   protected Component rightComponent;
 217: 
 218:   /** Determines how extra space should be allocated. */
 219:   private transient double resizeWeight;
 220: 
 221:   /**
 222:    * Creates a new JSplitPane object with the given orientation, layout mode,
 223:    * and left and right components.
 224:    *
 225:    * @param newOrientation The orientation to use.
 226:    * @param newContinuousLayout The layout mode to use.
 227:    * @param newLeftComponent The left component.
 228:    * @param newRightComponent The right component.
 229:    *
 230:    * @throws IllegalArgumentException DOCUMENT ME!
 231:    */
 232:   public JSplitPane(int newOrientation, boolean newContinuousLayout,
 233:                     Component newLeftComponent, Component newRightComponent)
 234:   {
 235:     if (newOrientation != HORIZONTAL_SPLIT && newOrientation != VERTICAL_SPLIT)
 236:       throw new IllegalArgumentException("orientation is invalid.");
 237:     orientation = newOrientation;
 238:     continuousLayout = newContinuousLayout;
 239:     setLeftComponent(newLeftComponent);
 240:     setRightComponent(newRightComponent);
 241: 
 242:     updateUI();
 243:   }
 244: 
 245:   /**
 246:    * Creates a new JSplitPane object using nonContinuousLayout mode, the given
 247:    * orientation and left and right components.
 248:    *
 249:    * @param newOrientation The orientation to use.
 250:    * @param newLeftComponent The left component.
 251:    * @param newRightComponent The right component.
 252:    */
 253:   public JSplitPane(int newOrientation, Component newLeftComponent,
 254:                     Component newRightComponent)
 255:   {
 256:     this(newOrientation, false, newLeftComponent, newRightComponent);
 257:   }
 258: 
 259:   /**
 260:    * Creates a new JSplitPane object with the given layout mode and
 261:    * orientation.
 262:    *
 263:    * @param newOrientation The orientation to use.
 264:    * @param newContinuousLayout The layout mode to use.
 265:    */
 266:   public JSplitPane(int newOrientation, boolean newContinuousLayout)
 267:   {
 268:     this(newOrientation, newContinuousLayout, null, null);
 269:   }
 270: 
 271:   /**
 272:    * Creates a new JSplitPane object using a nonContinuousLayout mode and the
 273:    * given orientation.
 274:    *
 275:    * @param newOrientation The orientation to use.
 276:    */
 277:   public JSplitPane(int newOrientation)
 278:   {
 279:     this(newOrientation, false, null, null);
 280:   }
 281: 
 282:   /**
 283:    * Creates a new JSplitPane object using HORIZONTAL_SPLIT and a
 284:    * nonContinuousLayout mode.
 285:    */
 286:   public JSplitPane()
 287:   {
 288:     this(HORIZONTAL_SPLIT, false, null, null);
 289:   }
 290: 
 291:   /**
 292:    * This method adds a component to the JSplitPane. The constraints object is
 293:    * a string that identifies where this component should go. If the
 294:    * constraints is not a known one, it will throw an
 295:    * IllegalArgumentException. The valid constraints are LEFT, TOP, RIGHT,
 296:    * BOTTOM and DIVIDER.
 297:    *
 298:    * @param comp The component to add.
 299:    * @param constraints The constraints string to use.
 300:    * @param index Where to place to component in the list of components.
 301:    *
 302:    * @throws IllegalArgumentException When the constraints is not a known identifier.
 303:    */
 304:   protected void addImpl(Component comp, Object constraints, int index)
 305:   {
 306:     int left = 0;
 307:     int right = 1;
 308:     int div = 2;
 309:     int place;
 310:     if (constraints == null)
 311:       {
 312:     if (leftComponent == null)
 313:       constraints = LEFT;
 314:     else if (rightComponent == null)
 315:       constraints = RIGHT;
 316:       }
 317: 
 318:     if (constraints instanceof String)
 319:       {
 320:     String placement = (String) constraints;
 321: 
 322:     if (placement.equals(BOTTOM) || placement.equals(RIGHT))
 323:       {
 324:         if (rightComponent != null)
 325:         remove(rightComponent);
 326:         rightComponent = comp;
 327:       }
 328:     else if (placement.equals(LEFT) || placement.equals(TOP))
 329:       {
 330:         if (leftComponent != null)
 331:           remove(leftComponent);
 332:         leftComponent = comp;
 333:       }
 334:     else if (placement.equals(DIVIDER))
 335:       constraints = null;
 336:     else
 337:       throw new IllegalArgumentException("Constraints is not a known identifier.");
 338: 
 339:     super.addImpl(comp, constraints, index);
 340:       }
 341:     invalidate();
 342:     layout();
 343:   }
 344: 
 345:   /**
 346:    * DOCUMENT ME!
 347:    *
 348:    * @return DOCUMENT ME!
 349:    */
 350:   public AccessibleContext getAccessibleContext()
 351:   {
 352:     if (accessibleContext == null)
 353:       accessibleContext = new AccessibleJSplitPane();
 354:     
 355:     return accessibleContext;
 356:   }
 357: 
 358:   /**
 359:    * This method returns the bottom component.
 360:    *
 361:    * @return The bottom component.
 362:    */
 363:   public Component getBottomComponent()
 364:   {
 365:     return rightComponent;
 366:   }
 367: 
 368:   /**
 369:    * This method returns the location of the divider. This method is passed to
 370:    * the UI.
 371:    *
 372:    * @return The location of the divider.
 373:    */
 374:   public int getDividerLocation()
 375:   {
 376:     if (ui != null)
 377:       return ((SplitPaneUI) ui).getDividerLocation(this);
 378:     else
 379:       return -1;
 380:   }
 381: 
 382:   /**
 383:    * This method returns the size of the divider.
 384:    *
 385:    * @return The size of the divider.
 386:    */
 387:   public int getDividerSize()
 388:   {
 389:     return dividerSize;
 390:   }
 391: 
 392:   /**
 393:    * This method returns the last divider location.
 394:    *
 395:    * @return The last divider location.
 396:    */
 397:   public int getLastDividerLocation()
 398:   {
 399:     return lastDividerLocation;
 400:   }
 401: 
 402:   /**
 403:    * This method returns the left component.
 404:    *
 405:    * @return The left component.
 406:    */
 407:   public Component getLeftComponent()
 408:   {
 409:     return leftComponent;
 410:   }
 411: 
 412:   /**
 413:    * This method returns the maximum divider location. This method is passed
 414:    * to  the UI.
 415:    *
 416:    * @return DOCUMENT ME!
 417:    */
 418:   public int getMaximumDividerLocation()
 419:   {
 420:     if (ui != null)
 421:       return ((SplitPaneUI) ui).getMaximumDividerLocation(this);
 422:     else
 423:       return -1;
 424:   }
 425: 
 426:   /**
 427:    * This method returns the minimum divider location. This method is passed
 428:    * to the UI.
 429:    *
 430:    * @return The minimum divider location.
 431:    */
 432:   public int getMinimumDividerLocation()
 433:   {
 434:     if (ui != null)
 435:       return ((SplitPaneUI) ui).getMinimumDividerLocation(this);
 436:     else
 437:       return -1;
 438:   }
 439: 
 440:   /**
 441:    * This method returns the orientation that the JSplitPane is using.
 442:    *
 443:    * @return The current orientation.
 444:    */
 445:   public int getOrientation()
 446:   {
 447:     return orientation;
 448:   }
 449: 
 450:   /**
 451:    * This method returns the current resize weight.
 452:    *
 453:    * @return The current resize weight.
 454:    */
 455:   public double getResizeWeight()
 456:   {
 457:     return resizeWeight;
 458:   }
 459: 
 460:   /**
 461:    * This method returns the right component.
 462:    *
 463:    * @return The right component.
 464:    */
 465:   public Component getRightComponent()
 466:   {
 467:     return rightComponent;
 468:   }
 469: 
 470:   /**
 471:    * This method returns the top component.
 472:    *
 473:    * @return The top component.
 474:    */
 475:   public Component getTopComponent()
 476:   {
 477:     return leftComponent;
 478:   }
 479: 
 480:   /**
 481:    * This method returns the UI.
 482:    *
 483:    * @return The UI.
 484:    */
 485:   public SplitPaneUI getUI()
 486:   {
 487:     return (SplitPaneUI) ui;
 488:   }
 489: 
 490:   /**
 491:    * This method returns true if the JSplitPane is using a continuousLayout.
 492:    *
 493:    * @return True if using a continuousLayout.
 494:    */
 495:   public boolean isContinuousLayout()
 496:   {
 497:     return continuousLayout;
 498:   }
 499: 
 500:   /**
 501:    * This method returns true if the divider has one touch expandable buttons.
 502:    *
 503:    * @return True if one touch expandable is used.
 504:    */
 505:   public boolean isOneTouchExpandable()
 506:   {
 507:     return oneTouchExpandable;
 508:   }
 509: 
 510:   /**
 511:    * This method returns true.
 512:    *
 513:    * @return true.
 514:    */
 515:   public boolean isValidateRoot()
 516:   {
 517:     return true;
 518:   }
 519: 
 520:   /**
 521:    * This method overrides JComponent's paintChildren so the UI can be
 522:    * messaged when the children have finished painting.
 523:    *
 524:    * @param g The Graphics object to paint with.
 525:    */
 526:   protected void paintChildren(Graphics g)
 527:   {
 528:     super.paintChildren(g);
 529:     if (ui != null)
 530:       ((SplitPaneUI) ui).finishedPaintingChildren(this, g);
 531:   }
 532: 
 533:   /**
 534:    * This method returns a String that describes this JSplitPane. The string
 535:    * is primarily used for debugging purposes.
 536:    *
 537:    * @return A String used for debugging purposes.
 538:    */
 539:   protected String paramString()
 540:   {
 541:     return "JSplitPane";
 542:   }
 543: 
 544:   /**
 545:    * This method removes the given component from the JSplitPane.
 546:    *
 547:    * @param component The Component to remove.
 548:    */
 549:   public void remove(Component component)
 550:   {
 551:     if (component == leftComponent)
 552:       leftComponent = null;
 553:     else if (component == rightComponent)
 554:       rightComponent = null;
 555:     super.remove(component);
 556:   }
 557: 
 558:   /**
 559:    * This method removes the component at the given index.
 560:    *
 561:    * @param index The index of the component to remove.
 562:    */
 563:   public void remove(int index)
 564:   {
 565:     Component component = getComponent(index);
 566:     if (component == leftComponent)
 567:       leftComponent = null;
 568:     else if (component == rightComponent)
 569:       rightComponent = null;
 570:     super.remove(index);
 571:   }
 572: 
 573:   /**
 574:    * This method removes all components from the JSplitPane.
 575:    */
 576:   public void removeAll()
 577:   {
 578:     leftComponent = null;
 579:     rightComponent = null;
 580:     super.removeAll();
 581:   }
 582: 
 583:   /**
 584:    * This method resets all children of the JSplitPane to their preferred
 585:    * sizes.
 586:    */
 587:   public void resetToPreferredSizes()
 588:   {
 589:     if (ui != null)
 590:       ((SplitPaneUI) ui).resetToPreferredSizes(this);
 591:   }
 592: 
 593:   /**
 594:    * This method sets the bottom component.
 595:    *
 596:    * @param comp The Component to be placed at the bottom.
 597:    */
 598:   public void setBottomComponent(Component comp)
 599:   {
 600:     if (comp != null)
 601:       add(comp, BOTTOM);
 602:     else
 603:       add(new JButton("right button"), BOTTOM);
 604:   }
 605: 
 606:   /**
 607:    * This method sets the layout mode for the JSplitPane.
 608:    *
 609:    * @param newContinuousLayout Whether the JSplitPane is in continuousLayout
 610:    *        mode.
 611:    */
 612:   public void setContinuousLayout(boolean newContinuousLayout)
 613:   {
 614:     if (newContinuousLayout != continuousLayout)
 615:       {
 616:     boolean oldValue = continuousLayout;
 617:     continuousLayout = newContinuousLayout;
 618:     firePropertyChange(CONTINUOUS_LAYOUT_PROPERTY, oldValue,
 619:                        continuousLayout);
 620:       }
 621:   }
 622: 
 623:   /**
 624:    * This method sets the location of the divider. A value of 0 sets the
 625:    * divider to the farthest left. A value of 1 sets the divider to the
 626:    * farthest right.
 627:    *
 628:    * @param proportionalLocation A double that describes the location of the
 629:    *        divider.
 630:    *
 631:    * @throws IllegalArgumentException DOCUMENT ME!
 632:    */
 633:   public void setDividerLocation(double proportionalLocation)
 634:   {
 635:     if (proportionalLocation > 1 || proportionalLocation < 0)
 636:       throw new IllegalArgumentException("proportion has to be between 0 and 1.");
 637: 
 638:     int max = (orientation == HORIZONTAL_SPLIT) ? getWidth() : getHeight();
 639:     setDividerLocation((int) (proportionalLocation * max));
 640:   }
 641: 
 642:   /**
 643:    * This method sets the location of the divider.
 644:    *
 645:    * @param location The location of the divider.
 646:    */
 647:   public void setDividerLocation(int location)
 648:   {
 649:     if (ui != null && location != getDividerLocation())
 650:       {
 651:     int oldLocation = getDividerLocation();
 652:     ((SplitPaneUI) ui).setDividerLocation(this, location);
 653:     firePropertyChange(DIVIDER_LOCATION_PROPERTY, oldLocation, location);
 654:       }
 655:   }
 656: 
 657:   /**
 658:    * This method sets the size of the divider.
 659:    *
 660:    * @param newSize The size of the divider.
 661:    */
 662:   public void setDividerSize(int newSize)
 663:   {
 664:     if (newSize != dividerSize)
 665:       {
 666:     int oldSize = dividerSize;
 667:     dividerSize = newSize;
 668:     firePropertyChange(DIVIDER_SIZE_PROPERTY, oldSize, dividerSize);
 669:       }
 670:   }
 671: 
 672:   // This doesn't appear to do anything when set from user side.
 673:   // so it probably is only used from the UI side to change the
 674:   // lastDividerLocation var.
 675: 
 676:   /**
 677:    * This method sets the last location of the divider.
 678:    *
 679:    * @param newLastLocation The last location of the divider.
 680:    */
 681:   public void setLastDividerLocation(int newLastLocation)
 682:   {
 683:     if (newLastLocation != lastDividerLocation)
 684:       {
 685:     int oldValue = lastDividerLocation;
 686:     lastDividerLocation = newLastLocation;
 687:     firePropertyChange(LAST_DIVIDER_LOCATION_PROPERTY, oldValue,
 688:                        lastDividerLocation);
 689:       }
 690:   }
 691: 
 692:   /**
 693:    * This method sets the left component.
 694:    *
 695:    * @param comp The left component.
 696:    */
 697:   public void setLeftComponent(Component comp)
 698:   {
 699:     if (comp != null)
 700:       add(comp, LEFT);
 701:     else
 702:       add(new JButton("left button"), LEFT);
 703:   }
 704: 
 705:   /**
 706:    * This method sets whether the divider has one touch expandable buttons.
 707:    * The one touch expandable buttons can expand the size of either component
 708:    * to the maximum allowed size.
 709:    *
 710:    * @param newValue Whether the divider will have one touch expandable
 711:    *        buttons.
 712:    */
 713:   public void setOneTouchExpandable(boolean newValue)
 714:   {
 715:     if (newValue != oneTouchExpandable)
 716:       {
 717:     boolean oldValue = oneTouchExpandable;
 718:     oneTouchExpandable = newValue;
 719:     firePropertyChange(ONE_TOUCH_EXPANDABLE_PROPERTY, oldValue,
 720:                        oneTouchExpandable);
 721:       }
 722:   }
 723: 
 724:   /**
 725:    * This method sets the orientation of the JSplitPane.
 726:    *
 727:    * @param orientation The orientation of the JSplitPane.
 728:    *
 729:    * @throws IllegalArgumentException DOCUMENT ME!
 730:    */
 731:   public void setOrientation(int orientation)
 732:   {
 733:     if (orientation != HORIZONTAL_SPLIT && orientation != VERTICAL_SPLIT)
 734:       throw new IllegalArgumentException("orientation must be one of VERTICAL_SPLIT, HORIZONTAL_SPLIT");
 735:     if (orientation != this.orientation)
 736:       {
 737:     int oldOrientation = this.orientation;
 738:     this.orientation = orientation;
 739:     firePropertyChange(ORIENTATION_PROPERTY, oldOrientation,
 740:                        this.orientation);
 741:       }
 742:   }
 743: 
 744:   /**
 745:    * This method determines how extra space will be distributed among the left
 746:    * and right components. A value of 0 will allocate all extra space to the
 747:    * right component. A value of 1 indicates that all extra space will go to
 748:    * the left component. A value in between 1 and 0 will split the space
 749:    * accordingly.
 750:    *
 751:    * @param value The resize weight.
 752:    */
 753:   public void setResizeWeight(double value)
 754:   {
 755:     resizeWeight = value;
 756:   }
 757: 
 758:   /**
 759:    * This method sets the right component.
 760:    *
 761:    * @param comp The right component.
 762:    */
 763:   public void setRightComponent(Component comp)
 764:   {
 765:     if (comp != null)
 766:       add(comp, RIGHT);
 767:     else
 768:     add(new JButton("right button"), RIGHT);
 769:   }
 770: 
 771:   /**
 772:    * This method sets the top component.
 773:    *
 774:    * @param comp The top component.
 775:    */
 776:   public void setTopComponent(Component comp)
 777:   {
 778:     if (comp != null)
 779:       add(comp, TOP);
 780:     else
 781:       add(new JButton("left button"), TOP);
 782:   }
 783: 
 784:   /**
 785:    * This method sets the UI used by the JSplitPane.
 786:    *
 787:    * @param ui The UI to use.
 788:    */
 789:   public void setUI(SplitPaneUI ui)
 790:   {
 791:     super.setUI(ui);
 792:   }
 793: 
 794:   /**
 795:    * This method resets the UI to the one specified by the current Look and
 796:    * Feel.
 797:    */
 798:   public void updateUI()
 799:   {
 800:     setUI((SplitPaneUI) UIManager.getUI(this));
 801:     invalidate();
 802:     repaint();
 803:   }
 804: 
 805:   /**
 806:    * This method returns a string identifier to determine which UI class it
 807:    * needs.
 808:    *
 809:    * @return A string that identifies it's UI class.
 810:    */
 811:   public String getUIClassID()
 812:   {
 813:     return "SplitPaneUI";
 814:   }
 815: }