javax.swing.plaf.basic

Class BasicTabbedPaneUI.TabbedPaneLayout

Enclosing Class:
BasicTabbedPaneUI
Implemented Interfaces:
LayoutManager
Known Direct Subclasses:
MetalTabbedPaneUI.TabbedPaneLayout

public class BasicTabbedPaneUI.TabbedPaneLayout
extends Object
implements LayoutManager

A LayoutManager responsible for placing all the tabs and the visible component inside the JTabbedPane. This class is only used for WRAP_TAB_LAYOUT.

Method Summary

void
addLayoutComponent(String name, Component comp)
This method is called when a component is added to the JTabbedPane.
void
calculateLayoutInfo()
This method is called when the rectangles need to be calculated.
protected Dimension
calculateSize(boolean minimum)
This method calculates the size of the the JTabbedPane.
protected void
calculateTabRects(int tabPlacement, int tabCount)
This method is called to calculate the tab rectangles.
void
layoutContainer(Container parent)
This method is called when the JTabbedPane is laid out in WRAP_TAB_LAYOUT.
Dimension
minimumLayoutSize(Container parent)
This method returns the minimum layout size for the given container.
protected void
normalizeTabRuns(int tabPlacement, int tabCount, int start, int max)
This method tries to "even out" the number of tabs in each run based on their widths.
protected void
padSelectedTab(int tabPlacement, int selectedIndex)
This method pads the tab at the selected index by the selected tab pad insets (so that it looks larger).
protected void
padTabRun(int tabPlacement, int start, int end, int max)
This method makes each tab in the run larger so that the tabs expand to fill the runs width/height (depending on tabPlacement).
Dimension
preferredLayoutSize(Container parent)
This method returns the preferred layout size for the given container.
protected int
preferredTabAreaHeight(int tabPlacement, int width)
This method returns the preferred tab height given a tabPlacement and width.
protected int
preferredTabAreaWidth(int tabPlacement, int height)
This method calculates the preferred tab area width given a tab placement and height.
void
removeLayoutComponent(Component comp)
This method is called when a component is removed from the JTabbedPane.
protected void
rotateTabRuns(int tabPlacement, int selectedRun)
This method rotates the places each run in the correct place the tabRuns array.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Details

addLayoutComponent

public void addLayoutComponent(String name,
                               Component comp)
This method is called when a component is added to the JTabbedPane.
Specified by:
addLayoutComponent in interface LayoutManager
Parameters:
name - The name of the component.
comp - The component being added.

calculateLayoutInfo

public void calculateLayoutInfo()
This method is called when the rectangles need to be calculated. It also fixes the size of the visible component.

calculateSize

protected Dimension calculateSize(boolean minimum)
This method calculates the size of the the JTabbedPane.
Parameters:
minimum - Whether the JTabbedPane will try to be as small as it can.
Returns:
The desired size of the JTabbedPane.

calculateTabRects

protected void calculateTabRects(int tabPlacement,
                                 int tabCount)
This method is called to calculate the tab rectangles. This method will calculate the size and position of all rectangles (taking into account which ones should be in which tab run). It will pad them and normalize them as necessary.
Parameters:
tabPlacement - The JTabbedPane's tab placement.
tabCount - The run the current selection is in.

layoutContainer

public void layoutContainer(Container parent)
This method is called when the JTabbedPane is laid out in WRAP_TAB_LAYOUT. It calls calculateLayoutInfo to find the positions of all its components.
Specified by:
layoutContainer in interface LayoutManager
Parameters:
parent - The Container to lay out.

minimumLayoutSize

public Dimension minimumLayoutSize(Container parent)
This method returns the minimum layout size for the given container.
Specified by:
minimumLayoutSize in interface LayoutManager
Parameters:
parent - The container that is being sized.
Returns:
The minimum size.

normalizeTabRuns

protected void normalizeTabRuns(int tabPlacement,
                                int tabCount,
                                int start,
                                int max)
This method tries to "even out" the number of tabs in each run based on their widths.
Parameters:
tabPlacement - The JTabbedPane's tab placement.
tabCount - The number of tabs.
start - The x position where the tabs will begin.
max - The maximum x position where the tab can run to.

padSelectedTab

protected void padSelectedTab(int tabPlacement,
                              int selectedIndex)
This method pads the tab at the selected index by the selected tab pad insets (so that it looks larger).
Parameters:
tabPlacement - The placement of the tabs.
selectedIndex - The selected index.

padTabRun

protected void padTabRun(int tabPlacement,
                         int start,
                         int end,
                         int max)
This method makes each tab in the run larger so that the tabs expand to fill the runs width/height (depending on tabPlacement).
Parameters:
tabPlacement - The placement of the tabs.
start - The index of the first tab.
end - The last index of the tab
max - The amount of space in the run (width for TOP and BOTTOM tabPlacement).

preferredLayoutSize

public Dimension preferredLayoutSize(Container parent)
This method returns the preferred layout size for the given container.
Specified by:
preferredLayoutSize in interface LayoutManager
Parameters:
parent - The container to size.
Returns:
The preferred layout size.

preferredTabAreaHeight

protected int preferredTabAreaHeight(int tabPlacement,
                                     int width)
This method returns the preferred tab height given a tabPlacement and width.
Parameters:
tabPlacement - The JTabbedPane's tab placement.
width - The expected width.
Returns:
The preferred tab area height.

preferredTabAreaWidth

protected int preferredTabAreaWidth(int tabPlacement,
                                    int height)
This method calculates the preferred tab area width given a tab placement and height.
Parameters:
tabPlacement - The JTabbedPane's tab placement.
height - The expected height.
Returns:
The preferred tab area width.

removeLayoutComponent

public void removeLayoutComponent(Component comp)
This method is called when a component is removed from the JTabbedPane.
Specified by:
removeLayoutComponent in interface LayoutManager
Parameters:
comp - The component removed.

rotateTabRuns

protected void rotateTabRuns(int tabPlacement,
                             int selectedRun)
This method rotates the places each run in the correct place the tabRuns array. See the comment for tabRuns for how the runs are placed in the array.
Parameters:
tabPlacement - The JTabbedPane's tab placement.
selectedRun - The run the current selection is in.

BasicTabbedPaneUI.java -- Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.