Class DynamicTabbedPane<T extends JPanel>
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTabbedPane
be.gaudry.swing.component.tabbedpane.DynamicTabbedPane<T>
- Type Parameters:
T- type of the component to show on the tabbed pane
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,Accessible,SwingConstants
- Direct Known Subclasses:
MetersTabbedPane,StudentCourseTabbedPane
The DynamicTabbedPane allows to close tabs and open new tabs
Provided by the broldev.core.swing project.
- Since:
- 1.0 (Jan 8, 2009), broldev.core.swing 0.0.1-SNAPSHOT dependency
- Version:
- 1.0 (Jan 8, 2009)
- Author:
- Steph GAUDRY
- See Also:
- Serialized Form
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JTabbedPane
JTabbedPane.AccessibleJTabbedPane, JTabbedPane.ModelListenerNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic StringSign displayed on a virtual tab to add a new tabprotected boolean(package private) JPanelFields inherited from class javax.swing.JTabbedPane
changeEvent, changeListener, model, SCROLL_TAB_LAYOUT, tabPlacement, WRAP_TAB_LAYOUTFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields 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
ConstructorsConstructorDescriptionBuilds an instance of tabbed pane with the ability to close tabsDynamicTabbedPane(boolean dynamicallyExpandable)Builds an instance of tabbed pane with the ability to close tabs and open new tabs if parameter is true -
Method Summary
Modifier and TypeMethodDescriptionabstract Stringabstract TThe implementation of getNewTabView must provides an instance of a <T> component to show when the new tab will be selected.getTabAt(int index)Returns a tab by its positionprotected StringbooleanisPseudoTab(int index)Determines if the index is this of the pseudo tab with the "add" featureprotected voidonCloseTab(int index)Removes the tab at the specified indexprotected TOverride this method if you want other things to happen when opening a new tab.
The override method may be like that :protected TPrepares the dynamic tabbed pane before adding the new tabvoidreset()Removes all opened tabsvoidsetSelectedIndex(int index)protected voidShows a component into a new tabMethods 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, setTabComponentAt, setTabLayoutPolicy, setTabPlacement, setTitleAt, setToolTipTextAt, setUI, updateUIMethods 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, updateMethods 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, validateTreeMethods 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
-
Field Details
-
DEFAULT_TITLE
Sign displayed on a virtual tab to add a new tab- See Also:
- Constant Field Values
-
dynamicallyExpandable
protected boolean dynamicallyExpandable -
parent
JPanel parent
-
-
Constructor Details
-
DynamicTabbedPane
public DynamicTabbedPane()Builds an instance of tabbed pane with the ability to close tabs -
DynamicTabbedPane
public DynamicTabbedPane(boolean dynamicallyExpandable)Builds an instance of tabbed pane with the ability to close tabs and open new tabs if parameter is true- Parameters:
dynamicallyExpandable- true to allow the user to add tabs
-
-
Method Details
-
getNewTabTitle
- Returns:
- the text shown on the new tab
-
getNewTabView
The implementation of getNewTabView must provides an instance of a <T> component to show when the new tab will be selected.- Returns:
- <T> component to associate to the new tab
-
isPseudoTab
public boolean isPseudoTab(int index)Determines if the index is this of the pseudo tab with the "add" feature- Parameters:
index- position of the tab to check- Returns:
- true if this is the pseudo tab position
-
onOpenNewTab
Override this method if you want other things to happen when opening a new tab.
The override method may be like that :public StudentQuotationsPanel onOpenNewTab() { StudentQuotationsPanel studentQuotationsPanel = null; if (availableCourses == null || availableCourses.size() < 1) { JOptionPane.showMessageDialog(this, getLocalized("student.noCourse2Add") + student.toString() + ".", getLocalized("course.add"), JOptionPane.INFORMATION_MESSAGE); } else { Course course = (Course) JOptionPane.showInputDialog(this, getLocalized("student.selectCourse2Add"), getLocalized("course.add"), JOptionPane.PLAIN_MESSAGE, BrolImagesEduCotation.COURSE_LOGO.getIcon(), availableCourses.toArray(new Course[0]), null); if (course != null) { startTab(course); } } return studentQuotationsPanel; }- Returns:
- null if selection failed or canceled, T object otherwise
-
onCloseTab
protected void onCloseTab(int index)Removes the tab at the specified index- Parameters:
index- position of the tab to close
-
prepareNewTab
Prepares the dynamic tabbed pane before adding the new tab- Returns:
- the component to put into the new tab
-
startTab
Shows a component into a new tab- Parameters:
newTabView- <T> object to add
-
getTabAt
Returns a tab by its position- Parameters:
index- position of the tab- Returns:
- <T> object found at the asked position
- Throws:
IllegalArgumentException- if the index is out of the range
-
getToolTipForClosing
-
reset
public void reset()Removes all opened tabs -
setSelectedIndex
public void setSelectedIndex(int index)- Overrides:
setSelectedIndexin classJTabbedPane
-