493 * RIGHT JTabbedPane.RIGHT |
493 * RIGHT JTabbedPane.RIGHT |
494 * description: The tabbedpane's tab placement. |
494 * description: The tabbedpane's tab placement. |
495 * |
495 * |
496 */ |
496 */ |
497 public void setTabPlacement(int tabPlacement) { |
497 public void setTabPlacement(int tabPlacement) { |
498 if (tabPlacement != TOP && tabPlacement != LEFT && |
498 checkTabPlacement(tabPlacement); |
499 tabPlacement != BOTTOM && tabPlacement != RIGHT) { |
|
500 throw new IllegalArgumentException("illegal tab placement: must be TOP, BOTTOM, LEFT, or RIGHT"); |
|
501 } |
|
502 if (this.tabPlacement != tabPlacement) { |
499 if (this.tabPlacement != tabPlacement) { |
503 int oldValue = this.tabPlacement; |
500 int oldValue = this.tabPlacement; |
504 this.tabPlacement = tabPlacement; |
501 this.tabPlacement = tabPlacement; |
505 firePropertyChange("tabPlacement", oldValue, tabPlacement); |
502 firePropertyChange("tabPlacement", oldValue, tabPlacement); |
506 revalidate(); |
503 revalidate(); |
507 repaint(); |
504 repaint(); |
|
505 } |
|
506 } |
|
507 |
|
508 private static void checkTabPlacement(int tabPlacement) { |
|
509 if (tabPlacement != TOP && tabPlacement != LEFT && |
|
510 tabPlacement != BOTTOM && tabPlacement != RIGHT) { |
|
511 throw new IllegalArgumentException("illegal tab placement:" |
|
512 + " must be TOP, BOTTOM, LEFT, or RIGHT"); |
508 } |
513 } |
509 } |
514 } |
510 |
515 |
511 /** |
516 /** |
512 * Returns the policy used by the tabbedpane to layout the tabs when all the |
517 * Returns the policy used by the tabbedpane to layout the tabs when all the |
549 * SCROLL_TAB_LAYOUT JTabbedPane.SCROLL_TAB_LAYOUT |
554 * SCROLL_TAB_LAYOUT JTabbedPane.SCROLL_TAB_LAYOUT |
550 * description: The tabbedpane's policy for laying out the tabs |
555 * description: The tabbedpane's policy for laying out the tabs |
551 * |
556 * |
552 */ |
557 */ |
553 public void setTabLayoutPolicy(int tabLayoutPolicy) { |
558 public void setTabLayoutPolicy(int tabLayoutPolicy) { |
554 if (tabLayoutPolicy != WRAP_TAB_LAYOUT && tabLayoutPolicy != SCROLL_TAB_LAYOUT) { |
559 checkTabLayoutPolicy(tabLayoutPolicy); |
555 throw new IllegalArgumentException("illegal tab layout policy: must be WRAP_TAB_LAYOUT or SCROLL_TAB_LAYOUT"); |
|
556 } |
|
557 if (this.tabLayoutPolicy != tabLayoutPolicy) { |
560 if (this.tabLayoutPolicy != tabLayoutPolicy) { |
558 int oldValue = this.tabLayoutPolicy; |
561 int oldValue = this.tabLayoutPolicy; |
559 this.tabLayoutPolicy = tabLayoutPolicy; |
562 this.tabLayoutPolicy = tabLayoutPolicy; |
560 firePropertyChange("tabLayoutPolicy", oldValue, tabLayoutPolicy); |
563 firePropertyChange("tabLayoutPolicy", oldValue, tabLayoutPolicy); |
561 revalidate(); |
564 revalidate(); |
562 repaint(); |
565 repaint(); |
|
566 } |
|
567 } |
|
568 |
|
569 private static void checkTabLayoutPolicy(int tabLayoutPolicy) { |
|
570 if (tabLayoutPolicy != WRAP_TAB_LAYOUT |
|
571 && tabLayoutPolicy != SCROLL_TAB_LAYOUT) { |
|
572 throw new IllegalArgumentException("illegal tab layout policy:" |
|
573 + " must be WRAP_TAB_LAYOUT or SCROLL_TAB_LAYOUT"); |
563 } |
574 } |
564 } |
575 } |
565 |
576 |
566 /** |
577 /** |
567 * Returns the currently selected index for this tabbedpane. |
578 * Returns the currently selected index for this tabbedpane. |
1814 * information about serialization in Swing. |
1825 * information about serialization in Swing. |
1815 */ |
1826 */ |
1816 private void readObject(ObjectInputStream s) |
1827 private void readObject(ObjectInputStream s) |
1817 throws IOException, ClassNotFoundException |
1828 throws IOException, ClassNotFoundException |
1818 { |
1829 { |
1819 s.defaultReadObject(); |
1830 ObjectInputStream.GetField f = s.readFields(); |
|
1831 |
|
1832 int newTabPlacement = f.get("tabPlacement", TOP); |
|
1833 checkTabPlacement(newTabPlacement); |
|
1834 tabPlacement = newTabPlacement; |
|
1835 int newTabLayoutPolicy = f.get("tabLayoutPolicy", 0); |
|
1836 checkTabLayoutPolicy(newTabLayoutPolicy); |
|
1837 tabLayoutPolicy = newTabLayoutPolicy; |
|
1838 model = (SingleSelectionModel) f.get("model", null); |
|
1839 haveRegistered = f.get("haveRegistered", false); |
|
1840 changeListener = (ChangeListener) f.get("changeListener", null); |
|
1841 visComp = (Component) f.get("visComp", null); |
|
1842 |
1820 if ((ui != null) && (getUIClassID().equals(uiClassID))) { |
1843 if ((ui != null) && (getUIClassID().equals(uiClassID))) { |
1821 ui.installUI(this); |
1844 ui.installUI(this); |
1822 } |
1845 } |
1823 // If ToolTipText != null, then the tooltip has already been |
1846 // If ToolTipText != null, then the tooltip has already been |
1824 // registered by JComponent.readObject() |
1847 // registered by JComponent.readObject() |