| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTabbedPane
org.xnap.commons.gui.CloseableTabbedPane
public class CloseableTabbedPane
Provides a JTabbedPane with close buttons  in the tab titles.
 The buttons of the currently active tab will be visible and the button
 of the tab the mouse if hovered over.
 
 
If a button is clicked the tab is removed from the pane unless a CloseListener has been set.
Note: If a button is displayed on a non active tab and the mouse is moved very fast out of the tabbed pane, the button may still be visible.
| Nested Class Summary | |
|---|---|
| static interface | CloseableTabbedPane.CloseListener | 
| static interface | CloseableTabbedPane.TabTitle | 
| protected  class | CloseableTabbedPane.TabTitleComponent | 
| protected  class | CloseableTabbedPane.TabTitleIconProvides an Icon that can displays a text that can have an icon to its left and an EventIconto its right. | 
| Nested classes/interfaces inherited from class javax.swing.JTabbedPane | 
|---|
| JTabbedPane.AccessibleJTabbedPane, JTabbedPane.ModelListener | 
| Nested classes/interfaces inherited from class javax.swing.JComponent | 
|---|
| JComponent.AccessibleJComponent | 
| Nested classes/interfaces inherited from class java.awt.Container | 
|---|
| Container.AccessibleAWTContainer | 
| Nested classes/interfaces inherited from class java.awt.Component | 
|---|
| Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy | 
| Field Summary | 
|---|
| Fields inherited from class javax.swing.JTabbedPane | 
|---|
| changeEvent, changeListener, model, SCROLL_TAB_LAYOUT, tabPlacement, WRAP_TAB_LAYOUT | 
| Fields inherited from class javax.swing.JComponent | 
|---|
| accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW | 
| Fields inherited from class java.awt.Component | 
|---|
| BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT | 
| Fields inherited from interface javax.swing.SwingConstants | 
|---|
| BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST | 
| Fields inherited from interface java.awt.image.ImageObserver | 
|---|
| ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH | 
| Constructor Summary | |
|---|---|
| CloseableTabbedPane()Creates a tabbed pane with close buttons and a WRAP_TAB_LAYOUT | |
| Method Summary | |
|---|---|
|  void | addTab(String title,
       Component component)Convenience wrapper for addTab(String, Component, null, true). | 
|  void | addTab(String title,
       Component component,
       Icon icon)Convenience wrapper for addTab(String, Component, Icon, true). | 
|  void | addTab(String title,
       Component component,
       Icon icon,
       boolean closeable)Adds a compnentwith a tabtitleand
 aniconto the tabbed pane. | 
|  String | getTitleAt(int index)This method does not work properly for tabs that have a close button. | 
|  void | removeTabAt(int index) | 
|  void | setCloseListener(CloseableTabbedPane.CloseListener listener)Sets the listener that is notified of user initiated close requests for single tabs. | 
|  void | setTabLayoutPolicy(int tabLayoutPolicy)Sets the tab layout policy. | 
|  void | setTitleAt(int index,
           String newTitle) | 
|  void | updateUI() | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Constructor Detail | 
|---|
public CloseableTabbedPane()
WRAP_TAB_LAYOUT
| Method Detail | 
|---|
public void setCloseListener(CloseableTabbedPane.CloseListener listener)
listener - can be null, then the component
 is simply removed
public void addTab(String title,
                   Component component,
                   Icon icon,
                   boolean closeable)
compnent with a tab title and
 an icon to the tabbed pane.
 The icon is displayed on the left side of the title and does not affect the icon of the closing button for this tab.
title - the title of the tab, can be nullcomponent - icon - can be nullcloseable - whether or not a close button should be displayed
 for this tabbed pane.
public void addTab(String title,
                   Component component,
                   Icon icon)
addTab(String, Component, Icon, true).
public void addTab(String title,
                   Component component)
addTab(String, Component, null, true).
addTab in class JTabbedPane
public void setTitleAt(int index,
                       String newTitle)
setTitleAt in class JTabbedPanepublic String getTitleAt(int index)
Keep that information somewhere else if you need it.
getTitleAt in class JTabbedPanepublic void setTabLayoutPolicy(int tabLayoutPolicy)
WRAP_TAB_LAYOUT is
 strongly recommended.
 
 
 Explanation: SCROLL_TAB_LAYOUT uses a private view
 translation for the scrolling of the tabs in
 BasicTabbedPaneUI. The EventIcon.paint()
 method receives coordinates from the ui view port and since it is not
 possible to translate coordinates between the tabbed pane and the view
 port the closing button can not be placed at the correct location.
 
 
 However there is a crude work around:
 TabbedPaneUI.getTabBounds() returns tabbed pane
 coordinates whereas TabTitleIcon.paint() receives view
 port coordinates. When TabTitleIcon.paint() is invoked it
 can finds out its tab bounds in tabbed pane coordinates and use those
 to set the button's bounds. The location can only be somewhat estimated
 as it depends on the tab style of the look&feel.
setTabLayoutPolicy in class JTabbedPanetabLayoutPolicy - must be JTabbedPane.WRAP_TAB_LAYOUTJTabbedPane.setTabLayoutPolicy(int)public void updateUI()
updateUI in class JTabbedPanepublic void removeTabAt(int index)
removeTabAt in class JTabbedPane| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||