Class CloseAndMaxTabbedPane
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JTabbedPane
-
- com.openindex.openestate.tool.utils.tabs.CloseAndMaxTabbedPane
-
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,Accessible,SwingConstants
public class CloseAndMaxTabbedPane extends JTabbedPane
A JTabbedPane with some added UI functionalities. A close and max/detach icons are added to every tab, typically to let the user close or detach the tab by clicking on these icons.- Author:
- David Bismut, davidou@mageos.com, Andreas Rudolph
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
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.BaselineResizeBehavior, 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
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
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
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
-
-
Constructor Summary
Constructors Constructor Description CloseAndMaxTabbedPane(boolean enhancedUI)Creates theCloseAndMaxTabbedPanewith an enhanced UI ifenhancedUIparameter is set totrue.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCloseListener(CloseListener l)Adds aCloseListenerto the tabbedPane.voidaddDoubleClickListener(DoubleClickListener l)Adds aDoubleClickListenerto the tabbedPane.voidaddMaxListener(MaxListener l)Adds aMaxListenerto the tabbedPane.voidaddPopupOutsideListener(PopupOutsideListener l)Adds aPopupOutsideListenerto the tabbedPane.voiddetachTab(int index)Detaches theindextab in a seperate frame.voidfireCloseTabEvent(MouseEvent e, int overTabIndex)Sends aMouseEvent, whose source is this tabbedpane, to everyCloseListener.voidfireDoubleClickTabEvent(MouseEvent e, int overTabIndex)Sends aMouseEvent, whose source is this tabbedpane, to everyDoubleClickListener.voidfireMaxTabEvent(MouseEvent e, int overTabIndex)Sends aMouseEvent, whose source is this tabbedpane, to everyMaxListener.voidfirePopupOutsideTabEvent(MouseEvent e)Sends aMouseEvent, whose source is this tabbedpane, to everyPopupOutsideListener.intgetOverTabIndex()Returns the index of the last tab on which the mouse did an action.booleanisCloseEnabled()Returnstrueif the close icon is enabled.booleanisMaxEnabled()Returnstrueif the max/detach icon is enabled.voidremoveCloseListener(CloseListener l)Removes aCloseListenerfrom this tabbedPane.voidremoveDoubleClickListener(DoubleClickListener l)Removes aDoubleClickListenerfrom this tabbedPane.voidremoveMaxListener(MaxListener l)Removes aMaxListenerfrom this tabbedPane.voidremovePopupOutsideListener(PopupOutsideListener l)Removes aPopupOutsideListenerfrom this tabbedPane.voidsetCloseIcon(boolean b)Sets whether the tabbedPane should have a close icon or not.voidsetCloseIcon(BufferedImage img)voidsetMaxIcon(boolean b)Sets whether the tabbedPane should have a max/detach icon or not.voidsetMaxIcon(BufferedImage img)voidsetTabLayoutPolicy(int tabLayoutPolicy)Override JTabbedPane method.voidsetTabPlacement(int tabPlacement)Override JTabbedPane method.voidsetUI(TabbedPaneUI ui)Override JTabbedPane method.-
Methods inherited from class javax.swing.JTabbedPane
add, add, add, add, add, addChangeListener, addTab, addTab, addTab, createChangeListener, fireStateChanged, getAccessibleContext, getBackgroundAt, getBoundsAt, getChangeListeners, getComponentAt, getDisabledIconAt, getDisplayedMnemonicIndexAt, getForegroundAt, getIconAt, getMnemonicAt, getModel, getSelectedComponent, getSelectedIndex, getTabComponentAt, getTabCount, getTabLayoutPolicy, getTabPlacement, getTabRunCount, getTitleAt, getToolTipText, getToolTipTextAt, getUI, getUIClassID, indexAtLocation, indexOfComponent, indexOfTab, indexOfTab, indexOfTabComponent, insertTab, isEnabledAt, paramString, remove, remove, removeAll, removeChangeListener, removeTabAt, setBackgroundAt, setComponentAt, setDisabledIconAt, setDisplayedMnemonicIndexAt, setEnabledAt, setForegroundAt, setIconAt, setMnemonicAt, setModel, setSelectedComponent, setSelectedIndex, setTabComponentAt, setTitleAt, setToolTipTextAt, updateUI
-
Methods inherited from class javax.swing.JComponent
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, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, 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, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
-
Methods inherited from class java.awt.Container
addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
-
Methods inherited from class java.awt.Component
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, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Method Detail
-
getOverTabIndex
public int getOverTabIndex()
Returns the index of the last tab on which the mouse did an action.- Returns:
-
isCloseEnabled
public boolean isCloseEnabled()
Returnstrueif the close icon is enabled.- Returns:
-
isMaxEnabled
public boolean isMaxEnabled()
Returnstrueif the max/detach icon is enabled.- Returns:
-
setTabLayoutPolicy
public void setTabLayoutPolicy(int tabLayoutPolicy)
Override JTabbedPane method. Does nothing.- Overrides:
setTabLayoutPolicyin classJTabbedPane
-
setTabPlacement
public void setTabPlacement(int tabPlacement)
Override JTabbedPane method. Does nothing.- Overrides:
setTabPlacementin classJTabbedPane
-
setUI
public void setUI(TabbedPaneUI ui)
Override JTabbedPane method. Does nothing.- Overrides:
setUIin classJTabbedPane
-
setCloseIcon
public void setCloseIcon(boolean b)
Sets whether the tabbedPane should have a close icon or not.- Parameters:
b- whether the tabbedPane should have a close icon or not
-
setCloseIcon
public void setCloseIcon(BufferedImage img)
-
setMaxIcon
public void setMaxIcon(boolean b)
Sets whether the tabbedPane should have a max/detach icon or not.- Parameters:
b- whether the tabbedPane should have a max/detach icon or not
-
setMaxIcon
public void setMaxIcon(BufferedImage img)
-
detachTab
public void detachTab(int index)
Detaches theindextab in a seperate frame. When the frame is closed, the tab is automatically reinserted into the tabbedPane.- Parameters:
index- index of the tabbedPane to be detached
-
addCloseListener
public void addCloseListener(CloseListener l)
Adds aCloseListenerto the tabbedPane.- Parameters:
l- theCloseListenerto add- See Also:
fireCloseTabEvent(java.awt.event.MouseEvent, int),removeCloseListener(com.openindex.openestate.tool.utils.tabs.CloseListener)
-
addMaxListener
public void addMaxListener(MaxListener l)
Adds aMaxListenerto the tabbedPane.- Parameters:
l- theMaxListenerto add- See Also:
fireMaxTabEvent(java.awt.event.MouseEvent, int),removeMaxListener(com.openindex.openestate.tool.utils.tabs.MaxListener)
-
addDoubleClickListener
public void addDoubleClickListener(DoubleClickListener l)
Adds aDoubleClickListenerto the tabbedPane.- Parameters:
l- theDoubleClickListenerto add- See Also:
fireDoubleClickTabEvent(java.awt.event.MouseEvent, int),removeDoubleClickListener(com.openindex.openestate.tool.utils.tabs.DoubleClickListener)
-
addPopupOutsideListener
public void addPopupOutsideListener(PopupOutsideListener l)
Adds aPopupOutsideListenerto the tabbedPane.- Parameters:
l- thePopupOutsideListenerto add- See Also:
firePopupOutsideTabEvent(java.awt.event.MouseEvent),removePopupOutsideListener(com.openindex.openestate.tool.utils.tabs.PopupOutsideListener)
-
removeCloseListener
public void removeCloseListener(CloseListener l)
Removes aCloseListenerfrom this tabbedPane.- Parameters:
l- theCloseListenerto remove- See Also:
fireCloseTabEvent(java.awt.event.MouseEvent, int),addCloseListener(com.openindex.openestate.tool.utils.tabs.CloseListener)
-
removeMaxListener
public void removeMaxListener(MaxListener l)
Removes aMaxListenerfrom this tabbedPane.- Parameters:
l- theMaxListenerto remove- See Also:
fireMaxTabEvent(java.awt.event.MouseEvent, int),addMaxListener(com.openindex.openestate.tool.utils.tabs.MaxListener)
-
removeDoubleClickListener
public void removeDoubleClickListener(DoubleClickListener l)
Removes aDoubleClickListenerfrom this tabbedPane.- Parameters:
l- theDoubleClickListenerto remove- See Also:
fireDoubleClickTabEvent(java.awt.event.MouseEvent, int),addDoubleClickListener(com.openindex.openestate.tool.utils.tabs.DoubleClickListener)
-
removePopupOutsideListener
public void removePopupOutsideListener(PopupOutsideListener l)
Removes aPopupOutsideListenerfrom this tabbedPane.- Parameters:
l- thePopupOutsideListenerto remove- See Also:
firePopupOutsideTabEvent(java.awt.event.MouseEvent),addPopupOutsideListener(com.openindex.openestate.tool.utils.tabs.PopupOutsideListener)
-
fireCloseTabEvent
public void fireCloseTabEvent(MouseEvent e, int overTabIndex)
Sends aMouseEvent, whose source is this tabbedpane, to everyCloseListener. The method also updates theoverTabIndexof the tabbedPane with a value coming from the UI. This method method is called each time aMouseEventis received from the UI when the user clicks on the close icon of the tab which index isoverTabIndex.- Parameters:
e- theMouseEventto be sentoverTabIndex- the index of a tab, usually the tab over which the mouse is- See Also:
addCloseListener(com.openindex.openestate.tool.utils.tabs.CloseListener)
-
fireMaxTabEvent
public void fireMaxTabEvent(MouseEvent e, int overTabIndex)
Sends aMouseEvent, whose source is this tabbedpane, to everyMaxListener. The method also updates theoverTabIndexof the tabbedPane with a value coming from the UI. This method method is called each time aMouseEventis received from the UI when the user clicks on the max icon of the tab which index isoverTabIndex.- Parameters:
e- theMouseEventto be sentoverTabIndex- the index of a tab, usually the tab over which the mouse is- See Also:
addMaxListener(com.openindex.openestate.tool.utils.tabs.MaxListener)
-
fireDoubleClickTabEvent
public void fireDoubleClickTabEvent(MouseEvent e, int overTabIndex)
Sends aMouseEvent, whose source is this tabbedpane, to everyDoubleClickListener. The method also updates theoverTabIndexof the tabbedPane with a value coming from the UI. This method method is called each time aMouseEventis received from the UI when the user double-clicks on the tab which index isoverTabIndex.- Parameters:
e- theMouseEventto be sentoverTabIndex- the index of a tab, usually the tab over which the mouse is- See Also:
addDoubleClickListener(com.openindex.openestate.tool.utils.tabs.DoubleClickListener)
-
firePopupOutsideTabEvent
public void firePopupOutsideTabEvent(MouseEvent e)
Sends aMouseEvent, whose source is this tabbedpane, to everyPopupOutsideListener. The method also sets theoverTabIndexto -1. This method method is called each time aMouseEventis received from the UI when the user right-clicks on the inactive part of a tabbedPane.- Parameters:
e- theMouseEventto be sent- See Also:
addPopupOutsideListener(com.openindex.openestate.tool.utils.tabs.PopupOutsideListener)
-
-