com.vlsolutions.swing.tabbedpane

Class JTabbedPaneSmartIcon

public class JTabbedPaneSmartIcon extends Object implements Icon, Cloneable

An Icon allowing the use of closeable tabs by simulating the entire tabpane tab-painting.

As JTabbedPanes cannot use any JComponents as tab selectors (the access if protected and we just have a label, an icon and a tooltip), we have to rely on tricks to bypass them.

UNKNOWN: 2005/11/01 Lilian Chamontin : fixed NPE when otherIcons == null (tabs without smart icons) 2005/11/08 Lilian Chamontin : fixed bug related to event management when multiple other-icons are used (big thanks to Emmanuel GAUVRIT). 2005/11/21 Lilian Chamontin : enhanced width calculation of the icon size.

Constructor Summary
JTabbedPaneSmartIcon(Icon icon, String label, SmartIconJButton[] otherIcons)
Constructs a new smart icon with a given set of additional buttons
Method Summary
Objectclone()
{@inheritDoc}
JTabbedPaneSmartIconcopy()
Creates a shalow copy of this icon
IcongetIcon()
Return the tab icon
intgetIconHeight()
Returns the height of this icon
intgetIconWidth()
Returns the width of this icon
StringgetLabel()
Return the tab label
StringgetLocalTooltipText()
Return the local tooltip of this icon (the one associated with inner mouse movements)
SmartIconJButtongetSmartButton(int index)
StringgetTooltipText()
Return the tooltip of this icon
booleanonMouseExited(MouseEvent e)
Process the mouse exited event.
booleanonMouseMoved(MouseEvent e)
Process the mouse moved event.
booleanonMousePressed(MouseEvent e)
Process the mouse pressed event.
booleanonMouseReleased(MouseEvent e)
Process the mouse released event.
voidpaintIcon(Component c, Graphics g, int x, int y)
paints the icon (and the associated label and sub-icons)
voidsetIcon(Icon icon)
Update the main icon (left) to be displayed on the tab
voidsetIconForTabbedPane(JTabbedPane container)
Specify which container will use this icon.
voidsetLabel(String label)
Update the label to be displayed on the tab
voidsetSmartButton(int index, SmartIconJButton btn)
voidsetTooltipText(String tooltip)
Update the tooltip of this icon

Constructor Detail

JTabbedPaneSmartIcon

public JTabbedPaneSmartIcon(Icon icon, String label, SmartIconJButton[] otherIcons)
Constructs a new smart icon with a given set of additional buttons

Method Detail

clone

public Object clone()
{@inheritDoc}

copy

public JTabbedPaneSmartIcon copy()
Creates a shalow copy of this icon

getIcon

public Icon getIcon()
Return the tab icon

getIconHeight

public int getIconHeight()
Returns the height of this icon

getIconWidth

public int getIconWidth()
Returns the width of this icon

getLabel

public String getLabel()
Return the tab label

getLocalTooltipText

public String getLocalTooltipText()
Return the local tooltip of this icon (the one associated with inner mouse movements)

getSmartButton

public SmartIconJButton getSmartButton(int index)

getTooltipText

public String getTooltipText()
Return the tooltip of this icon

onMouseExited

public boolean onMouseExited(MouseEvent e)
Process the mouse exited event.

Mouse coordinates are given relative to this icon

onMouseMoved

public boolean onMouseMoved(MouseEvent e)
Process the mouse moved event.

Mouse coordinates are given relative to this icon

onMousePressed

public boolean onMousePressed(MouseEvent e)
Process the mouse pressed event.

Mouse coordinates are given relative to this icon

onMouseReleased

public boolean onMouseReleased(MouseEvent e)
Process the mouse released event.

Mouse coordinates are given relative to this icon

paintIcon

public void paintIcon(Component c, Graphics g, int x, int y)
paints the icon (and the associated label and sub-icons)

setIcon

public void setIcon(Icon icon)
Update the main icon (left) to be displayed on the tab

setIconForTabbedPane

public void setIconForTabbedPane(JTabbedPane container)
Specify which container will use this icon.

If the icon is shared between containers, please provide at least one as this allows the icon to properly estimate its dimension.

setLabel

public void setLabel(String label)
Update the label to be displayed on the tab

setSmartButton

public void setSmartButton(int index, SmartIconJButton btn)

setTooltipText

public void setTooltipText(String tooltip)
Update the tooltip of this icon
© Copyright 2004-2005 VLSolutions. All Rights Reserved.
www.vlsolutions.com : Java Components - Smart Client Applications