|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--java.awt.Panel | +--com.magelang.tabsplitter.TabPanel | +--com.magelang.tabsplitter.TabSplitter
TabSplitter -- allows a user to select from several interface components by clicking a tab at the top of the panel. In addition, it allows the user to merge any tabs together into a a single tab using a SplitterLayout.
Each contained component is represented by a tab at the top of the TabSplitter, much like file folders in a file cabinet. When a tab is clicked, it becomes the "selected" tab and its associated component will be displayed.
There are two types of navigational aids provided with the TabSplitter. If there are more tabs than can be displayed in the current window, two triangle buttons will appear. These buttons will scroll the set of tabs left and right.
There are also two buttons marked "+" and "-". These buttons move the user through each tab in succession.
To properly set up a tab panel, you need to do two things:
The thing that sets this tabbed panel apart is how it reacts to mouse drags on its tabs. Click on a tab and drag it to any other tab. The "source" tab will be merged into the "target" tab, combined via a panel with a SplitterLayout. The target tab's text will be modified to list both previous tab texts. In addition, each sub panel that has been merged will have a Button placed above it with the old tab text for that component. Clicking on this button will separate out the subpanel on its own tab once again.
Note: It is extremely important that the user of this tab panel not try to directly use the layoutmanger (via getLayout() and setLayout() ). These two methods could not be overridden to prevent modification, as many GUI builders expect to use it. If you want to switch between tabs, use the "next()" and "previous()" methods provided by TabSplitter, not those of CardLayout.
Use this code at your own risk! MageLang Institute is not responsible for any damage caused directly or indirctly through use of this code.
Use this code at your own risk! MageLang Institute is not responsible for any damage caused directly or indirectly through use of this code.
SOFTWARE RIGHTS
TabSplitter, version 2.0, Scott Stanchfield, MageLang Institute
We reserve no legal rights to this code--it is fully in the public domain. An individual or company may do whatever they wish with source code distributed with it, including including the incorporation of it into commerical software.
However, this code cannot be sold as a standalone product.
We encourage users to develop software with this code. However, we do ask that credit is given to us for developing it By "credit", we mean that if you use these components or incorporate any source code into one of your programs (commercial product, research project, or otherwise) that you acknowledge this fact somewhere in the documentation, research report, etc... If you like these components and have developed a nice tool with the output, please mention that you developed it using these components. In addition, we ask that the headers remain intact in our source code. As long as these guidelines are kept, we expect to continue enhancing this system and expect to make other tools available as they are completed.
The MageLang Support Classes Gang:
SplitterLayout
,
TabPanel
, Serialized FormInner classes inherited from class java.awt.Panel |
java.awt.Panel.AccessibleAWTPanel |
Inner classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
Inner classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent |
Fields inherited from class com.magelang.tabsplitter.TabPanel |
aTabSelectionListener, leftArrow, leftEnabled, rightArrow, rightEnabled |
Fields inherited from class java.awt.Component |
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 |
Constructor Summary | |
TabSplitter()
Constructor |
Method Summary | |
void |
actionPerformed(java.awt.event.ActionEvent e)
Handle the menu selection events -- just adds in our processing for the swap orientation menu item |
protected void |
addImpl(java.awt.Component comp,
java.lang.Object constraints,
int index)
adds a component to the TabSplitter. |
protected void |
findWhereToAdd(java.lang.String name,
java.awt.Component comp)
Determine where the component should be placed based on its position when added to the TabSplitter |
protected int |
getMaxPos()
|
protected int |
getPosition(java.lang.Object comp)
Return the position of the component in the tabsplitter (its physical tab number) |
java.lang.Object |
getVisibleComponent()
Get the component that is currently visible |
int[] |
getVisibleComponentNum()
Get an array of selected component numbers. |
protected void |
mergeOrShow(int n)
Determine if we want to merge a tab or just select one |
protected void |
mergeTabs(int target,
int source)
Merges two tabs' components onto one tab by putting them both on a splitter panel |
void |
mouseDragged(java.awt.event.MouseEvent e)
|
void |
mouseExited(java.awt.event.MouseEvent e)
Handle the mouse exiting the TabSplitter |
void |
mouseMoved(java.awt.event.MouseEvent e)
|
void |
mousePressed(java.awt.event.MouseEvent e)
Handle the mouse being pressed on a TabSplitter |
void |
mouseReleased(java.awt.event.MouseEvent e)
Handle the mouse being released on a tabsplitter |
void |
remove(java.awt.Component comp)
Remove a component from the container. |
void |
remove(int index)
Remove a component from the container. |
void |
removeAll()
Remove all components from the container. |
void |
separateTabs(java.lang.String name1,
java.awt.Component comp1,
java.lang.String exp1,
java.lang.String name2,
java.awt.Component comp2,
java.lang.String exp2,
com.magelang.tabsplitter.SplitterPanel p)
separateTabs -- split the selected tab out from its parent Splitterlayout panel |
void |
setFont(java.awt.Font f)
Set the font to use when writing the tab text |
void |
show(java.awt.Component comp)
Show a component. |
void |
show(int n)
Show the nth tab (starting at 0) The number refers to the tab added in the nth position to the tab splitter, not the actual nth tab on the panel. |
void |
show(java.lang.String tabName)
Show a component based on tab name This method will find where the component with the specified text is located and display it, even if it is in a SplitterPanel |
void |
swapOrientation()
Change the orientation (horizontal/vertical) of all SplitterPanels |
Methods inherited from class com.magelang.tabsplitter.TabPanel |
addTabSelectionListener, determineTabText, determineVisible, drawTabs, fireTabSelected, getBorderColor, getExplicitTabText, getFirstVisible, getInsets, getPopupMenu, getSelectedName, getSelectedTabNum, getTabBackground, getTabColor, getTabColors, getTabColors, getTabText, getTabText, mouseClicked, mouseEntered, next, paint, previous, removeTabSelectionListener, selectTab, setBorderColor, setExplicitTabText, setFirstVisible, setSelectedTabNum, setTabBackground, setTabColor, setTabColors, setTabColors, setTabText, setTabText, setupTabPolygons, shiftLeft, shiftRight, showPhysicalTab, showPopup, tabContains, update |
Methods inherited from class java.awt.Panel |
addNotify, getAccessibleContext |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, removeContainerListener, removeNotify, setLayout, validate, validateTree |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.awt.event.MouseListener |
mouseClicked, mouseEntered |
Constructor Detail |
public TabSplitter()
Method Detail |
public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
actionPerformed
in class TabPanel
com.magelang.tabsplitter.TabPanel
e
- (java.awt.event.ActionEvent) -- the event that was fired to usprotected void addImpl(java.awt.Component comp, java.lang.Object constraints, int index)
addImpl
in class TabPanel
comp
- (java.awt.Component) -- the component to be addedconstraints
- (java.lang.Object) -- constraints on the componentindex
- (int) -- at which position will the component be addedprotected void findWhereToAdd(java.lang.String name, java.awt.Component comp)
protected int getMaxPos()
protected int getPosition(java.lang.Object comp)
TabPanel
getPosition
in class TabPanel
com.magelang.tabsplitter.TabPanel
comp
- (Component) -- the component to search for.public java.lang.Object getVisibleComponent()
getVisibleComponent
in class TabPanel
public int[] getVisibleComponentNum()
getVisibleComponentNum
in class TabPanel
protected void mergeOrShow(int n)
mergeOrShow
in class TabPanel
com.magelang.tabsplitter.TabPanel
n
- (int) -- the target tab or a merge or tab to showprotected void mergeTabs(int target, int source)
public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
mouseExited
in class TabPanel
public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
mousePressed
in class TabPanel
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
mouseReleased
in class TabPanel
com.magelang.tabsplitter.TabPanel
e
- (MouseEvent)public void remove(int index)
remove
in class TabPanel
index
- (int) Which component to remove.public void remove(java.awt.Component comp)
TabPanel
remove
in class TabPanel
com.magelang.tabsplitter.TabPanel
comp
- (Component) Which component to remove.public void removeAll()
removeAll
in class TabPanel
public void separateTabs(java.lang.String name1, java.awt.Component comp1, java.lang.String exp1, java.lang.String name2, java.awt.Component comp2, java.lang.String exp2, com.magelang.tabsplitter.SplitterPanel p)
public void setFont(java.awt.Font f)
setFont
in class TabPanel
com.magelang.tabsplitter.TabPanel
f
- (Font) -- the font to use when writing tab textpublic void show(int n)
show
in class TabPanel
com.magelang.tabsplitter.TabPanel
n
- (int) the number of the tab to selectpublic void show(java.awt.Component comp)
show
in class TabPanel
com.magelang.tabsplitter.TabPanel
comp
- (Component) the main component of the tab to selectpublic void show(java.lang.String tabName)
show
in class TabPanel
com.magelang.tabsplitter.TabPanel
tabName
- (String) the text of the tab to be selectedpublic void swapOrientation()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |