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