com.isti.util.gui
Class TabCloseIcon

java.lang.Object
  extended bycom.isti.util.gui.TabCloseIcon
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, javax.swing.Icon

public class TabCloseIcon
extends java.lang.Object
implements javax.swing.Icon, java.awt.event.ActionListener

Class TabCloseIcon defines an icon to be used to close tabs on a JTabbedPane.


Nested Class Summary
static interface TabCloseIcon.CloseTab
          The close tab interface.
protected static class TabCloseIcon.TabCloseIconMouseListener
          The mouse listener for all tab close icons.
 
Constructor Summary
TabCloseIcon()
          Creates a new instance of TabCloseIcon.
TabCloseIcon(javax.swing.Icon icon)
          Creates a new instance of TabCloseIcon.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent evtObj)
          Invoked when a context-popup-menu item is selected.
protected  void closeTab(int idx)
          Close the tab by removing it from the tabbed pane.
protected  boolean contains(java.awt.event.MouseEvent e)
          Determines if the event happened on the icon.
 java.awt.Color getColor()
          Gets the color.
static boolean getFavoriteTabFlagForTab(javax.swing.JTabbedPane tPaneObj, java.awt.Component compObj)
          Determines whether or not the specified tab is marked as a favorite.
 int getIconHeight()
          Returns the icon's height.
 int getIconWidth()
          Returns the icon's width.
static boolean getShowFavTabMenuItemFlag()
          Determines whether or not the "Favorite Tab" menu item will be shown on context popup menus for 'TabCloseIcon' tabs.
 boolean isFavoriteTab()
          Determines whether or not this tab is marked as a favorite.
protected  void paintDefaultIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)
          Draw the default icon at the specified location.
 void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)
          Draw the icon at the specified location.
 void setColor(java.awt.Color colorObj)
          Sets the color.
 void setFavoriteTabFlag(boolean flgVal)
          Sets whether or not this tab is marked as a favorite.
static void setFavoriteTabFlagForTab(javax.swing.JTabbedPane tPaneObj, java.awt.Component compObj, boolean flgVal)
          Sets whether or not the specified tab is marked as a favorite.
 TabCloseIcon setGroup(java.lang.String group, java.util.Set groupSet)
          Sets the group text for the tab.
static void setShowFavTabMenuItemFlag(boolean flgVal)
          Sets whether or not the "Favorite Tab" menu item will be shown on context popup menus for 'TabCloseIcon' tabs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TabCloseIcon

public TabCloseIcon()
Creates a new instance of TabCloseIcon.


TabCloseIcon

public TabCloseIcon(javax.swing.Icon icon)
Creates a new instance of TabCloseIcon.

Parameters:
icon - the icon or null for the default image.
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evtObj)
Invoked when a context-popup-menu item is selected.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
evtObj - associated action-event object.

paintIcon

public void paintIcon(java.awt.Component c,
                      java.awt.Graphics g,
                      int x,
                      int y)
Draw the icon at the specified location.

Specified by:
paintIcon in interface javax.swing.Icon
Parameters:
c - the component.
g - the graphics.
x - the x position.
y - the y position.

getColor

public java.awt.Color getColor()
Gets the color.

Returns:
the color or null for default.

getIconWidth

public int getIconWidth()
Returns the icon's width.

Specified by:
getIconWidth in interface javax.swing.Icon
Returns:
an int specifying the fixed width of the icon.

getIconHeight

public int getIconHeight()
Returns the icon's height.

Specified by:
getIconHeight in interface javax.swing.Icon
Returns:
an int specifying the fixed height of the icon.

setColor

public void setColor(java.awt.Color colorObj)
Sets the color.

Parameters:
colorObj - the color to use.

setGroup

public TabCloseIcon setGroup(java.lang.String group,
                             java.util.Set groupSet)
Sets the group text for the tab.

Parameters:
group - the group text.
groupSet - the group set.
Returns:
the 'TabCloseIcon'.

setFavoriteTabFlag

public void setFavoriteTabFlag(boolean flgVal)
Sets whether or not this tab is marked as a favorite. Any tab marked as a favorite will not be closed when a "Close All..." menu item is invoked.

Parameters:
flgVal - true to mark this tab as a favorite; false to not.

isFavoriteTab

public boolean isFavoriteTab()
Determines whether or not this tab is marked as a favorite. Any tab marked as a favorite will not be closed when a "Close All..." menu item is invoked.

Returns:
true if this tab is marked as a favorite; false if not.

setFavoriteTabFlagForTab

public static void setFavoriteTabFlagForTab(javax.swing.JTabbedPane tPaneObj,
                                            java.awt.Component compObj,
                                            boolean flgVal)
Sets whether or not the specified tab is marked as a favorite. Any tab marked as a favorite will not be closed when a "Close All..." menu item is invoked.

Parameters:
tPaneObj - tabbed pane hosting the tab.
compObj - component on tab.
flgVal - true to mark tab as a favorite; false to not.

getFavoriteTabFlagForTab

public static boolean getFavoriteTabFlagForTab(javax.swing.JTabbedPane tPaneObj,
                                               java.awt.Component compObj)
Determines whether or not the specified tab is marked as a favorite. Any tab marked as a favorite will not be closed when a "Close All..." menu item is invoked.

Parameters:
tPaneObj - tabbed pane hosting the tab.
compObj - component on tab.
Returns:
true if tab is marked as a favorite; false if not (or if no matching tab was found).

setShowFavTabMenuItemFlag

public static void setShowFavTabMenuItemFlag(boolean flgVal)
Sets whether or not the "Favorite Tab" menu item will be shown on context popup menus for 'TabCloseIcon' tabs. This settings applies to all 'TabCloseIcon' tabs. The default value is 'false' (not shown).

Parameters:
flgVal - true to show the "Favorite Tab" menu item on the context popup menus; false to not show.

getShowFavTabMenuItemFlag

public static boolean getShowFavTabMenuItemFlag()
Determines whether or not the "Favorite Tab" menu item will be shown on context popup menus for 'TabCloseIcon' tabs. This settings applies to all 'TabCloseIcon' tabs.

Returns:
true if the "Favorite Tab" menu item is shown; false if not.

closeTab

protected void closeTab(int idx)
Close the tab by removing it from the tabbed pane.

Parameters:
idx - the tab index.

contains

protected boolean contains(java.awt.event.MouseEvent e)
Determines if the event happened on the icon.

Parameters:
e - the MouseEvent.
Returns:
true if the event happened on the icon, false otherwise.

paintDefaultIcon

protected void paintDefaultIcon(java.awt.Component c,
                                java.awt.Graphics g,
                                int x,
                                int y)
Draw the default icon at the specified location.

Parameters:
c - the component.
g - the graphics.
x - the x position.
y - the y position.