com.vlsolutions.swing.tabbedpane
Class JTabbedPaneSmartIcon

java.lang.Object
  extended by com.vlsolutions.swing.tabbedpane.JTabbedPaneSmartIcon
All Implemented Interfaces:
java.lang.Cloneable, javax.swing.Icon

public class JTabbedPaneSmartIcon
extends java.lang.Object
implements javax.swing.Icon, java.lang.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.


Constructor Summary
JTabbedPaneSmartIcon(javax.swing.Icon icon, java.lang.String label, SmartIconJButton[] otherIcons)
          Constructs a new smart icon with a given set of additional buttons
 
Method Summary
 java.lang.Object clone()
          
 JTabbedPaneSmartIcon copy()
          Creates a shalow copy of this icon
 javax.swing.Icon getIcon()
          Return the tab icon
 int getIconHeight()
          Returns the height of this icon
 int getIconWidth()
          Returns the width of this icon
 java.lang.String getLabel()
          Return the tab label
 java.lang.String getLocalTooltipText()
          Return the local tooltip of this icon (the one associated with inner mouse movements)
 SmartIconJButton getSmartButton(int index)
           
 java.lang.String getTooltipText()
          Return the tooltip of this icon
 boolean onMouseExited(java.awt.event.MouseEvent e)
          Process the mouse exited event.
 boolean onMouseMoved(java.awt.event.MouseEvent e)
          Process the mouse moved event.
 boolean onMousePressed(java.awt.event.MouseEvent e)
          Process the mouse pressed event.
 boolean onMouseReleased(java.awt.event.MouseEvent e)
          Process the mouse released event.
 void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)
          paints the icon (and the associated label and sub-icons)
 void setIcon(javax.swing.Icon icon)
          Update the main icon (left) to be displayed on the tab
 void setIconForTabbedPane(javax.swing.JTabbedPane container)
          Specify which container will use this icon.
 void setLabel(java.lang.String label)
          Update the label to be displayed on the tab
 void setSmartButton(int index, SmartIconJButton btn)
           
 void setTooltipText(java.lang.String tooltip)
          Update the tooltip of this icon
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JTabbedPaneSmartIcon

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

Method Detail

getSmartButton

public SmartIconJButton getSmartButton(int index)

setSmartButton

public void setSmartButton(int index,
                           SmartIconJButton btn)

copy

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


clone

public java.lang.Object clone()

Overrides:
clone in class java.lang.Object

setTooltipText

public void setTooltipText(java.lang.String tooltip)
Update the tooltip of this icon


getTooltipText

public java.lang.String getTooltipText()
Return the tooltip of this icon


getLocalTooltipText

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


setLabel

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


getLabel

public java.lang.String getLabel()
Return the tab label


setIcon

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


getIcon

public javax.swing.Icon getIcon()
Return the tab icon


setIconForTabbedPane

public void setIconForTabbedPane(javax.swing.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.


paintIcon

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

Specified by:
paintIcon in interface javax.swing.Icon

getIconWidth

public int getIconWidth()
Returns the width of this icon

Specified by:
getIconWidth in interface javax.swing.Icon

getIconHeight

public int getIconHeight()
Returns the height of this icon

Specified by:
getIconHeight in interface javax.swing.Icon

onMousePressed

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

Mouse coordinates are given relative to this icon


onMouseReleased

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

Mouse coordinates are given relative to this icon


onMouseExited

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

Mouse coordinates are given relative to this icon


onMouseMoved

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

Mouse coordinates are given relative to this icon



© Copyright 2004-2007 VLSolutions. All Rights Reserved.
www.vlsolutions.com : Java Components - Smart Client Applications