public class CustomTab
extends javax.swing.JPanel
implements javax.swing.SwingConstants, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, javax.swing.event.ListDataListener
Modifier and Type | Class and Description |
---|---|
protected class |
CustomTab.AccessibleCustomTab |
javax.swing.JPanel.AccessibleJPanel
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
static double |
SELECTED_STYLE_CENTER
The icon and text are centered
|
static double |
SELECTED_STYLE_FIXED
The icon and text do not move when selected
|
static double |
SELECTED_STYLE_MOVE
The icon and text move by the specified offsetSelected.
|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Constructor and Description |
---|
CustomTab(int position) |
CustomTab(javax.swing.ListModel model,
int position) |
Modifier and Type | Method and Description |
---|---|
void |
addListDataListener(javax.swing.event.ListDataListener listener)
Equivalent to getModel().addListDataListener() except that by using this method, you are guaranteed that the
selectedPage is already adjusted.
|
void |
addSelectionListener(javax.swing.event.ListSelectionListener l) |
java.awt.Rectangle |
calculateLabelRectangle(CustomTabPage page,
int viewPos) |
void |
contentsChanged(javax.swing.event.ListDataEvent e) |
void |
doLayout() |
javax.accessibility.AccessibleContext |
getAccessibleContext() |
static java.awt.Color |
getColorLines() |
int |
getCornerSize() |
int |
getGapAboveLabel() |
int |
getGapAfterTabs() |
int |
getGapBeforeTabs() |
int |
getGapBelowLabel() |
int |
getGapBetweenTabs() |
int |
getGapCenter() |
int |
getGapClose() |
int |
getGapLeft() |
int |
getGapRight() |
java.awt.Dimension |
getMaximumSize() |
java.awt.Dimension |
getMinimumSize() |
int |
getMinTabHeight()
Returns the minimum height for the tabs.
|
javax.swing.ListModel |
getModel() |
int |
getOffsetSelected() |
CustomTabPage |
getPage(int at) |
int |
getPageAfter(int xPos)
Gets the first page located after the
xPos position. |
int |
getPageAt(java.awt.Point pt)
Gets the page located under
pt |
int |
getPageBefore(int xPos)
Gets the first page located before the
xPos position. |
int |
getPageCount() |
int |
getPosition() |
java.awt.Dimension |
getPreferredSize() |
int |
getSelectedPage() |
double |
getSelectedStyle() |
boolean |
getShowIcons()
Deprecated.
Replaced by
isShowIcons() |
java.awt.Point |
getToolTipLocation(java.awt.event.MouseEvent event) |
java.lang.String |
getToolTipText(java.awt.event.MouseEvent event) |
void |
intervalAdded(javax.swing.event.ListDataEvent e) |
void |
intervalRemoved(javax.swing.event.ListDataEvent e) |
void |
invalidate() |
boolean |
isFitWidth()
Returns whether the tabs will be stretched horizontally to fit the
width of the control.
|
boolean |
isFocused() |
boolean |
isGradientHighlight() |
boolean |
isShowIcons()
Gets the
showIcons property. |
boolean |
isShowSelectedCloseButton() |
boolean |
isShowTabUnderline()
Returns whether the bottom tab underline will be drawn.
|
void |
mouseClicked(java.awt.event.MouseEvent e) |
void |
mouseDragged(java.awt.event.MouseEvent e) |
void |
mouseEntered(java.awt.event.MouseEvent e) |
void |
mouseExited(java.awt.event.MouseEvent e) |
void |
mouseMoved(java.awt.event.MouseEvent e) |
void |
mousePressed(java.awt.event.MouseEvent e) |
void |
mouseReleased(java.awt.event.MouseEvent e) |
protected void |
paintComponent(java.awt.Graphics gAWT) |
protected void |
paintTabs(java.awt.Graphics2D g) |
void |
removeAllPages() |
void |
removeListDataListener(javax.swing.event.ListDataListener listener)
removes a listener that has been set with
addListDataListener(javax.swing.event.ListDataListener) |
void |
removePage(CustomTabPage customTabPage) |
CustomTabPage |
removePage(int at) |
void |
removeSelectionListener(javax.swing.event.ListSelectionListener l) |
int |
searchPage(CustomTabPage customTabPage) |
void |
setActive(boolean active) |
void |
setCloseAction(javax.swing.Action closeAction)
Sets the action to perform when the close button is pressed, or when a
tab is closed via control-click.
|
void |
setCompressible(boolean compressible)
If set to true and the component does not have enough space to show all the tabs, it will compress the text
Note This option is not implemented yet.
|
void |
setCornerSize(int cornerSize)
Sets the size of the corner
|
void |
setCtrlClickCloseEnabled(boolean ctrlClickCloseEnabled) |
void |
setDirty(int page,
boolean dirty)
Sets the specified
CustomTabPage dirty attribute |
void |
setFitWidth(boolean fitWidth)
Sets whether the tabs should be stretched horizontally to fit the
width of the control.
|
void |
setFocused(boolean focused) |
void |
setFont(java.awt.Font font) |
void |
setGapAboveLabel(int gapAboveLabel)
Sets the gap between the label and the top of the tab
|
void |
setGapAfterTabs(int gapAfterTabs)
Sets the gap after the last tab
|
void |
setGapBeforeTabs(int gapBeforeTabs)
Sets the gap before the first tab
|
void |
setGapBelowLabel(int gapBelowLabel)
Sets the gap between the label and the bottom of the tab
|
void |
setGapBetweenTabs(int gapBetweenTabs)
Sets the gap between two tabs
|
void |
setGapCenter(int gapCenter)
Sets the gap between the icon and the text
|
void |
setGapClose(int gapClose) |
void |
setGapLeft(int gapLeft)
Sets the gap between the left border of the tab and the icon (or text if there is no icon)
|
void |
setGapRight(int gapRight)
Sets the gap between the text (or icon if there is no text) and the right border of the tab
|
void |
setGradientHighlight(boolean isGradientHighlight) |
void |
setHighlighted(int page,
boolean highlighted)
Sets the specified
CustomTabPage highlighted attribute |
void |
setMaxTabChars(int maxTabChars)
Sets the maximum chars in a tab.
|
void |
setMinTabHeight(int minTabHeight)
Sets the minimum tab height.
|
void |
setMinTabWidth(int minTabWidth)
Sets the minimum tab width.
|
void |
setModel(javax.swing.ListModel model) |
void |
setOffsetSelected(int offsetSelected)
Sets the offset by which the tab moves when selected
|
void |
setPosition(int position) |
void |
setSelectedPage(int page) |
void |
setSelectedPageViaMouse()
Open a page, usually initiated by a caught drag action in a listening DropTarget.
|
void |
setSelectedStyle(double selectedStyle)
Determines how the icon and text moves when the tab is selected.
|
void |
setShowIcons(boolean showIcons)
Sets the
showIcons property, which must be
true for tab icons to appear. |
void |
setShowSelectedCloseButton(boolean showSelectedCloseButton) |
void |
setShowTabUnderline(boolean showTabUnderline)
Sets whether the bottom tab underline should be drawn.
|
void |
setTabComponentOwner(javax.swing.JComponent tabOwner)
Sets the component as the owner of the CustomTab.
|
void |
whenTabChanged()
Call this method when you change the title or icon of the tab
|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public static final double SELECTED_STYLE_FIXED
public static final double SELECTED_STYLE_CENTER
public static final double SELECTED_STYLE_MOVE
public CustomTab(int position)
position
- takes values from SwingConstants.BOTTOM
and SwingConstants.TOP
public CustomTab(javax.swing.ListModel model, int position)
model
- data modelposition
- takes values from SwingConstants.BOTTOM
and SwingConstants.TOP
public javax.accessibility.AccessibleContext getAccessibleContext()
getAccessibleContext
in interface javax.accessibility.Accessible
getAccessibleContext
in class javax.swing.JPanel
public javax.swing.ListModel getModel()
public void setModel(javax.swing.ListModel model)
public void setCloseAction(javax.swing.Action closeAction)
The tooltip for the close button is taken from the Action.SHORT_DESCRIPTION
property of the closeAction.
closeAction
- the action to perform when the close button is
pressedpublic void setCtrlClickCloseEnabled(boolean ctrlClickCloseEnabled)
public void addSelectionListener(javax.swing.event.ListSelectionListener l)
public void removeSelectionListener(javax.swing.event.ListSelectionListener l)
public int getPosition()
public void setPosition(int position)
position
- takes values from SwingConstants.TOP & BOTTOMpublic void setCompressible(boolean compressible)
compressible
- public void setMaxTabChars(int maxTabChars)
maxTabChars
- public void setMinTabWidth(int minTabWidth)
minTabWidth
- public int getMinTabHeight()
public void setMinTabHeight(int minTabHeight)
minTabHeight
- the minimum height for the tabspublic static java.awt.Color getColorLines()
public boolean getShowIcons()
isShowIcons()
public boolean isShowIcons()
showIcons
property.public void setShowIcons(boolean showIcons)
showIcons
property, which must be
true
for tab icons to appear. The default value is
true
.public boolean isShowTabUnderline()
true
.public void setShowTabUnderline(boolean showTabUnderline)
public boolean isFitWidth()
false
.public void setFitWidth(boolean fitWidth)
public boolean isGradientHighlight()
public void setGradientHighlight(boolean isGradientHighlight)
public boolean isFocused()
public void setFocused(boolean focused)
public void setActive(boolean active)
public boolean isShowSelectedCloseButton()
public void setShowSelectedCloseButton(boolean showSelectedCloseButton)
public CustomTabPage removePage(int at)
public void removePage(CustomTabPage customTabPage)
public void removeAllPages()
public int getPageCount()
public int searchPage(CustomTabPage customTabPage)
public CustomTabPage getPage(int at)
public void setSelectedPage(int page)
public int getSelectedPage()
public int getPageAt(java.awt.Point pt)
pt
pt
- public int getPageBefore(int xPos)
xPos
position.
For example:
| returns 2 | returns 2 | returns 1 +---+ +---+ +---+ | 1 | | 2 | | 3 | --------+ +--------
xPos
- xPos
public int getPageAfter(int xPos)
xPos
position.
For example:
| returns 3 | returns 3 | returns 3 +---+ +---+ +---+ | 1 | | 2 | | 3 | --------+ +--------
xPos
- xPos
public void setDirty(int page, boolean dirty)
CustomTabPage
dirty attributepage
- page whose dirty attribute is to be setdirty
- true if the page is dirty, false otherwisepublic void setHighlighted(int page, boolean highlighted)
CustomTabPage
highlighted attributepage
- page whose hightlighted attribute is to be sethighlighted
- true if the page's tab is to be highlighted, false otherwisepublic java.awt.Dimension getMinimumSize()
getMinimumSize
in class javax.swing.JComponent
public java.awt.Dimension getMaximumSize()
getMaximumSize
in class javax.swing.JComponent
public java.awt.Dimension getPreferredSize()
getPreferredSize
in class javax.swing.JComponent
public void doLayout()
doLayout
in class java.awt.Container
public void invalidate()
invalidate
in class java.awt.Container
public void setFont(java.awt.Font font)
setFont
in class javax.swing.JComponent
public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
public void whenTabChanged()
public void addListDataListener(javax.swing.event.ListDataListener listener)
removeListDataListener(javax.swing.event.ListDataListener)
listener
- public void removeListDataListener(javax.swing.event.ListDataListener listener)
addListDataListener(javax.swing.event.ListDataListener)
listener
- public void intervalAdded(javax.swing.event.ListDataEvent e)
intervalAdded
in interface javax.swing.event.ListDataListener
public void intervalRemoved(javax.swing.event.ListDataEvent e)
intervalRemoved
in interface javax.swing.event.ListDataListener
public void contentsChanged(javax.swing.event.ListDataEvent e)
contentsChanged
in interface javax.swing.event.ListDataListener
public java.lang.String getToolTipText(java.awt.event.MouseEvent event)
getToolTipText
in class javax.swing.JComponent
public java.awt.Point getToolTipLocation(java.awt.event.MouseEvent event)
getToolTipLocation
in class javax.swing.JComponent
public java.awt.Rectangle calculateLabelRectangle(CustomTabPage page, int viewPos)
public int getGapBeforeTabs()
public void setGapBeforeTabs(int gapBeforeTabs)
public int getGapBetweenTabs()
public void setGapBetweenTabs(int gapBetweenTabs)
gapBetweenTabs
- public int getGapAfterTabs()
public void setGapAfterTabs(int gapAfterTabs)
gapAfterTabs
- public int getGapAboveLabel()
public void setGapAboveLabel(int gapAboveLabel)
gapAboveLabel
- public int getGapBelowLabel()
public void setGapBelowLabel(int gapBelowLabel)
gapBelowLabel
- public int getGapLeft()
public void setGapLeft(int gapLeft)
gapLeft
- public int getGapCenter()
public void setGapCenter(int gapCenter)
gapCenter
- public int getGapRight()
public int getGapClose()
public void setGapClose(int gapClose)
public void setGapRight(int gapRight)
gapRight
- public int getOffsetSelected()
public void setOffsetSelected(int offsetSelected)
offsetSelected
- public int getCornerSize()
public void setCornerSize(int cornerSize)
cornerSize
- public double getSelectedStyle()
public void setSelectedStyle(double selectedStyle)
selectedStyle
- takes values from SELECTED_STYLE_FIXED
, SELECTED_STYLE_CENTER
or
SELECTED_STYLE_MOVE
protected void paintComponent(java.awt.Graphics gAWT)
paintComponent
in class javax.swing.JComponent
protected void paintTabs(java.awt.Graphics2D g)
public void setSelectedPageViaMouse()
public void setTabComponentOwner(javax.swing.JComponent tabOwner)
tabOwner
-