< prev index next >

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java

Print this page




2378                 int columns = 1;
2379                 int y = 0;
2380                 int fontHeight = metrics.getHeight();
2381 
2382                 maxTabWidth = calculateMaxTabWidth(tabPlacement);
2383 
2384                 for (int i = 0; i < tabCount; i++) {
2385                     int tabHeight = calculateTabHeight(tabPlacement, i, fontHeight);
2386 
2387                     if (y != 0 && y + tabHeight > height) {
2388                         columns++;
2389                         y = 0;
2390                     }
2391                     y += tabHeight;
2392                 }
2393                 total = calculateTabAreaWidth(tabPlacement, columns, maxTabWidth);
2394             }
2395             return total;
2396         }
2397 

2398         public void layoutContainer(Container parent) {
2399             /* Some of the code in this method deals with changing the
2400             * visibility of components to hide and show the contents for the
2401             * selected tab. This is older code that has since been duplicated
2402             * in JTabbedPane.fireStateChanged(), so as to allow visibility
2403             * changes to happen sooner (see the note there). This code remains
2404             * for backward compatibility as there are some cases, such as
2405             * subclasses that don't fireStateChanged() where it may be used.
2406             * Any changes here need to be kept in synch with
2407             * JTabbedPane.fireStateChanged().
2408             */
2409 
2410             setRolloverTab(-1);
2411 
2412             int tabPlacement = tabPane.getTabPlacement();
2413             Insets insets = tabPane.getInsets();
2414             int selectedIndex = tabPane.getSelectedIndex();
2415             Component visibleComponent = getVisibleComponent();
2416 
2417             calculateLayoutInfo();


2886                         int right = (selRect.x + selRect.width) + insets.right - size.width;
2887                         if (right > 0) {
2888                             selRect.width -= right;
2889                         }
2890                     }
2891                 }
2892             }
2893         }
2894     }
2895 
2896     private class TabbedPaneScrollLayout extends TabbedPaneLayout {
2897 
2898         protected int preferredTabAreaHeight(int tabPlacement, int width) {
2899             return calculateMaxTabHeight(tabPlacement);
2900         }
2901 
2902         protected int preferredTabAreaWidth(int tabPlacement, int height) {
2903             return calculateMaxTabWidth(tabPlacement);
2904         }
2905 

2906         public void layoutContainer(Container parent) {
2907             /* Some of the code in this method deals with changing the
2908              * visibility of components to hide and show the contents for the
2909              * selected tab. This is older code that has since been duplicated
2910              * in JTabbedPane.fireStateChanged(), so as to allow visibility
2911              * changes to happen sooner (see the note there). This code remains
2912              * for backward compatibility as there are some cases, such as
2913              * subclasses that don't fireStateChanged() where it may be used.
2914              * Any changes here need to be kept in synch with
2915              * JTabbedPane.fireStateChanged().
2916              */
2917 
2918             setRolloverTab(-1);
2919 
2920             int tabPlacement = tabPane.getTabPlacement();
2921             int tabCount = tabPane.getTabCount();
2922             Insets insets = tabPane.getInsets();
2923             int selectedIndex = tabPane.getSelectedIndex();
2924             Component visibleComponent = getVisibleComponent();
2925 




2378                 int columns = 1;
2379                 int y = 0;
2380                 int fontHeight = metrics.getHeight();
2381 
2382                 maxTabWidth = calculateMaxTabWidth(tabPlacement);
2383 
2384                 for (int i = 0; i < tabCount; i++) {
2385                     int tabHeight = calculateTabHeight(tabPlacement, i, fontHeight);
2386 
2387                     if (y != 0 && y + tabHeight > height) {
2388                         columns++;
2389                         y = 0;
2390                     }
2391                     y += tabHeight;
2392                 }
2393                 total = calculateTabAreaWidth(tabPlacement, columns, maxTabWidth);
2394             }
2395             return total;
2396         }
2397 
2398         @SuppressWarnings("deprecation")
2399         public void layoutContainer(Container parent) {
2400             /* Some of the code in this method deals with changing the
2401             * visibility of components to hide and show the contents for the
2402             * selected tab. This is older code that has since been duplicated
2403             * in JTabbedPane.fireStateChanged(), so as to allow visibility
2404             * changes to happen sooner (see the note there). This code remains
2405             * for backward compatibility as there are some cases, such as
2406             * subclasses that don't fireStateChanged() where it may be used.
2407             * Any changes here need to be kept in synch with
2408             * JTabbedPane.fireStateChanged().
2409             */
2410 
2411             setRolloverTab(-1);
2412 
2413             int tabPlacement = tabPane.getTabPlacement();
2414             Insets insets = tabPane.getInsets();
2415             int selectedIndex = tabPane.getSelectedIndex();
2416             Component visibleComponent = getVisibleComponent();
2417 
2418             calculateLayoutInfo();


2887                         int right = (selRect.x + selRect.width) + insets.right - size.width;
2888                         if (right > 0) {
2889                             selRect.width -= right;
2890                         }
2891                     }
2892                 }
2893             }
2894         }
2895     }
2896 
2897     private class TabbedPaneScrollLayout extends TabbedPaneLayout {
2898 
2899         protected int preferredTabAreaHeight(int tabPlacement, int width) {
2900             return calculateMaxTabHeight(tabPlacement);
2901         }
2902 
2903         protected int preferredTabAreaWidth(int tabPlacement, int height) {
2904             return calculateMaxTabWidth(tabPlacement);
2905         }
2906 
2907         @SuppressWarnings("deprecation")
2908         public void layoutContainer(Container parent) {
2909             /* Some of the code in this method deals with changing the
2910              * visibility of components to hide and show the contents for the
2911              * selected tab. This is older code that has since been duplicated
2912              * in JTabbedPane.fireStateChanged(), so as to allow visibility
2913              * changes to happen sooner (see the note there). This code remains
2914              * for backward compatibility as there are some cases, such as
2915              * subclasses that don't fireStateChanged() where it may be used.
2916              * Any changes here need to be kept in synch with
2917              * JTabbedPane.fireStateChanged().
2918              */
2919 
2920             setRolloverTab(-1);
2921 
2922             int tabPlacement = tabPane.getTabPlacement();
2923             int tabCount = tabPane.getTabCount();
2924             Insets insets = tabPane.getInsets();
2925             int selectedIndex = tabPane.getSelectedIndex();
2926             Component visibleComponent = getVisibleComponent();
2927 


< prev index next >