Package adams.gui.core
Class SplitPanelWithOptionalComponents
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- adams.gui.core.BasePanel
-
- adams.gui.core.SplitPanelWithOptionalComponents
-
- All Implemented Interfaces:
CleanUpHandler,ImageObserver,MenuContainer,Serializable,Accessible
public class SplitPanelWithOptionalComponents extends BasePanel implements CleanUpHandler
A panel that has optional left/top or right/bottom components. If both are visible, then a split pane is used.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
-
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 Modifier and Type Field Description protected JComponentm_LeftComponentthe left component.protected booleanm_LeftDetachablewhether the left component is detachable.protected booleanm_LeftDetachableButtonVisiblewhether a button to detach left component is visible.protected DetachablePanelm_LeftDetachablePanelthe detachable panel for the left component.protected intm_Orientationthe orientation.protected JComponentm_RightComponentthe right component.protected booleanm_RightDetachablewhether the right component is detachable.protected booleanm_RightDetachableButtonVisiblewhether a button to detach right component is visible.protected DetachablePanelm_RightDetachablePanelthe detachable panel for the right component.protected BaseSplitPanem_SplitPanethe split pane.-
Fields inherited from class adams.gui.core.BasePanel
m_FileChooser
-
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
-
-
Constructor Summary
Constructors Constructor Description SplitPanelWithOptionalComponents()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcleanUp()Cleans up data structures, frees up memory.protected voidfinishInit()Finishes the initialization.JComponentgetBottomComponent()Returns the bottom component.intgetDividerLocation()Return the divider location.JComponentgetLeftComponent()Returns the left component.StringgetLeftDetachedFrameTitle()Returns the frame title for the detached left component.intgetOrientation()Returns the current orientation:JSplitPane.HORIZONTAL_SPLIT,JSplitPane.VERTICAL_SPLIT.doublegetResizeWeight()Returns the number that determines how extra space is distributed.JComponentgetRightComponent()Returns the right component.StringgetRightDetachedFrameTitle()Returns the frame title for the detached right component.JComponentgetTopComponent()Returns the top component.protected voidinitGUI()Initializes the members.protected voidinitialize()Initializes the members.booleanisBottomDetachable()Returns whether the bottom component is detachable.booleanisBottomDetachableButtonVisible()Returns the frame title for the detached bottom component.booleanisLeftDetachable()Returns whether the left component is detachable.booleanisLeftDetachableButtonVisible()Returns the frame title for the detached left component.booleanisRightDetachable()Returns whether the right component is detachable.booleanisRightDetachableButtonVisible()Returns the frame title for the detached right component.booleanisTopDetachable()Returns whether the top component is detachable.booleanisTopDetachableButtonVisible()Returns the frame title for the detached top component.protected JComponentmakeDetachableIfNecessary(JComponent component, boolean left)Wraps the component in a detachable panel, if necessary.voidremoveBottomComponent()Removes the bottom component.voidremoveLeftComponent()Removes the left component.voidremoveRightComponent()Removes the right component.voidremoveTopComponent()Removes the top component.voidsetBottomComponent(JComponent value)Sets the bottom component.voidsetBottomDetachable(boolean value)Sets whether the bottom component is detachable.voidsetBottomDetachableButtonVisible(boolean value)Sets whether the button to detach the bottom component is visible.voidsetDividerLocation(int location)Return the divider location.voidsetLeftComponent(JPanel value)Sets the left component.voidsetLeftDetachable(boolean value)Sets whether the left component is detachable.voidsetLeftDetachableButtonVisible(boolean value)Sets whether the button to detach the left component is visible.voidsetLeftDetachedFrameTitle(String value)Sets the frame title for the detached left component.voidsetOrientation(int value)Sets the orientation:JSplitPane.HORIZONTAL_SPLIT,JSplitPane.VERTICAL_SPLIT.voidsetResizeWeight(double value)Specifies how to distribute extra space when the size of the split pane changes.voidsetRightComponent(JComponent value)Sets the right component.voidsetRightDetachable(boolean value)Sets whether the right component is detachable.voidsetRightDetachableButtonVisible(boolean value)Sets whether the button to detach the right component is visible.voidsetRightDetachedFrameTitle(String value)Sets the frame title for the detached right component.voidsetTopComponent(JPanel value)Sets the top component.voidsetTopDetachable(boolean value)Sets whether the top component is detachable.voidsetTopDetachableButtonVisible(boolean value)Sets whether the button to detach the top component is visible.voidsetUISettingsParameters(Class cls)Sets the class to use for the UI settings.protected voidupdate()Updates the layout.-
Methods inherited from class adams.gui.core.BasePanel
afterHide, afterShow, beforeHide, beforeShow, closeParent, getParentChild, getParentDialog, getParentFrame, getParentInternalFrame, getParentTitle, initFileChooser, main, printErrorMessage, printException, saveComponent, setEnabledCascade, setEnabledCascade, setParentTitle, setVisible
-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, 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, 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, unregisterKeyboardAction, update
-
Methods inherited from class java.awt.Container
add, add, add, add, add, 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, remove, remove, removeAll, 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
-
-
-
-
Field Detail
-
m_SplitPane
protected BaseSplitPane m_SplitPane
the split pane.
-
m_LeftDetachablePanel
protected DetachablePanel m_LeftDetachablePanel
the detachable panel for the left component.
-
m_LeftComponent
protected JComponent m_LeftComponent
the left component.
-
m_RightDetachablePanel
protected DetachablePanel m_RightDetachablePanel
the detachable panel for the right component.
-
m_RightComponent
protected JComponent m_RightComponent
the right component.
-
m_Orientation
protected int m_Orientation
the orientation.
-
m_LeftDetachable
protected boolean m_LeftDetachable
whether the left component is detachable.
-
m_RightDetachable
protected boolean m_RightDetachable
whether the right component is detachable.
-
m_LeftDetachableButtonVisible
protected boolean m_LeftDetachableButtonVisible
whether a button to detach left component is visible.
-
m_RightDetachableButtonVisible
protected boolean m_RightDetachableButtonVisible
whether a button to detach right component is visible.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initializein classBasePanel
-
finishInit
protected void finishInit()
Finishes the initialization.- Overrides:
finishInitin classBasePanel
-
setUISettingsParameters
public void setUISettingsParameters(Class cls)
Sets the class to use for the UI settings.- Parameters:
cls- the class to use
-
setOrientation
public void setOrientation(int value)
Sets the orientation:JSplitPane.HORIZONTAL_SPLIT,JSplitPane.VERTICAL_SPLIT.- Parameters:
value- the new orientation
-
getOrientation
public int getOrientation()
Returns the current orientation:JSplitPane.HORIZONTAL_SPLIT,JSplitPane.VERTICAL_SPLIT.- Returns:
- the new orientation
-
setLeftComponent
public void setLeftComponent(JPanel value)
Sets the left component.- Parameters:
value- the left component, null to remove
-
getLeftComponent
public JComponent getLeftComponent()
Returns the left component.- Returns:
- the left component, can be null
-
removeLeftComponent
public void removeLeftComponent()
Removes the left component.
-
setRightComponent
public void setRightComponent(JComponent value)
Sets the right component.- Parameters:
value- the right component, null to remove
-
getRightComponent
public JComponent getRightComponent()
Returns the right component.- Returns:
- the right component, can be null
-
removeRightComponent
public void removeRightComponent()
Removes the right component.
-
setTopComponent
public void setTopComponent(JPanel value)
Sets the top component.- Parameters:
value- the top component, can be null
-
getTopComponent
public JComponent getTopComponent()
Returns the top component.- Returns:
- the top component, can be null
-
removeTopComponent
public void removeTopComponent()
Removes the top component.
-
setBottomComponent
public void setBottomComponent(JComponent value)
Sets the bottom component.- Parameters:
value- the bottom component, null to use empty panel
-
getBottomComponent
public JComponent getBottomComponent()
Returns the bottom component.- Returns:
- the bottom component
-
removeBottomComponent
public void removeBottomComponent()
Removes the bottom component.
-
setLeftDetachable
public void setLeftDetachable(boolean value)
Sets whether the left component is detachable.- Parameters:
value- true if to be detachable
-
isLeftDetachable
public boolean isLeftDetachable()
Returns whether the left component is detachable.- Returns:
- true if detachable
-
setRightDetachable
public void setRightDetachable(boolean value)
Sets whether the right component is detachable.- Parameters:
value- true if to be detachable
-
isRightDetachable
public boolean isRightDetachable()
Returns whether the right component is detachable.- Returns:
- true if detachable
-
setTopDetachable
public void setTopDetachable(boolean value)
Sets whether the top component is detachable.- Parameters:
value- true if to be detachable
-
isTopDetachable
public boolean isTopDetachable()
Returns whether the top component is detachable.- Returns:
- true if detachable
-
setBottomDetachable
public void setBottomDetachable(boolean value)
Sets whether the bottom component is detachable.- Parameters:
value- true if to be detachable
-
isBottomDetachable
public boolean isBottomDetachable()
Returns whether the bottom component is detachable.- Returns:
- true if detachable
-
setLeftDetachedFrameTitle
public void setLeftDetachedFrameTitle(String value)
Sets the frame title for the detached left component.- Parameters:
value- the title
-
getLeftDetachedFrameTitle
public String getLeftDetachedFrameTitle()
Returns the frame title for the detached left component.- Returns:
- the title
-
setRightDetachedFrameTitle
public void setRightDetachedFrameTitle(String value)
Sets the frame title for the detached right component.- Parameters:
value- the title
-
getRightDetachedFrameTitle
public String getRightDetachedFrameTitle()
Returns the frame title for the detached right component.- Returns:
- the title
-
setLeftDetachableButtonVisible
public void setLeftDetachableButtonVisible(boolean value)
Sets whether the button to detach the left component is visible.- Parameters:
value- true if visible
-
isLeftDetachableButtonVisible
public boolean isLeftDetachableButtonVisible()
Returns the frame title for the detached left component.- Returns:
- true if visible
-
setRightDetachableButtonVisible
public void setRightDetachableButtonVisible(boolean value)
Sets whether the button to detach the right component is visible.- Parameters:
value- true if visible
-
isRightDetachableButtonVisible
public boolean isRightDetachableButtonVisible()
Returns the frame title for the detached right component.- Returns:
- true if visible
-
setTopDetachableButtonVisible
public void setTopDetachableButtonVisible(boolean value)
Sets whether the button to detach the top component is visible.- Parameters:
value- true if visible
-
isTopDetachableButtonVisible
public boolean isTopDetachableButtonVisible()
Returns the frame title for the detached top component.- Returns:
- true if visible
-
setBottomDetachableButtonVisible
public void setBottomDetachableButtonVisible(boolean value)
Sets whether the button to detach the bottom component is visible.- Parameters:
value- true if visible
-
isBottomDetachableButtonVisible
public boolean isBottomDetachableButtonVisible()
Returns the frame title for the detached bottom component.- Returns:
- true if visible
-
setDividerLocation
public void setDividerLocation(int location)
Return the divider location.- Parameters:
location- the divider location
-
getDividerLocation
public int getDividerLocation()
Return the divider location.- Returns:
- the divider location
-
setResizeWeight
public void setResizeWeight(double value)
Specifies how to distribute extra space when the size of the split pane changes. A value of 0, the default, indicates the right/bottom component gets all the extra space (the left/top component acts fixed), where as a value of 1 specifies the left/top component gets all the extra space (the right/bottom component acts fixed). Specifically, the left/top component gets (weight * diff) extra space and the right/bottom component gets (1 - weight) * diff extra space.- Parameters:
value- as described above- Throws:
IllegalArgumentException- ifvalueis < 0 or > 1
-
getResizeWeight
public double getResizeWeight()
Returns the number that determines how extra space is distributed.- Returns:
- how extra space is to be distributed on a resize of the split pane
-
makeDetachableIfNecessary
protected JComponent makeDetachableIfNecessary(JComponent component, boolean left)
Wraps the component in a detachable panel, if necessary.- Parameters:
component- the component to wrapleft- whether left or right component- Returns:
- the (potentially) wrapped component
-
update
protected void update()
Updates the layout.
-
cleanUp
public void cleanUp()
Cleans up data structures, frees up memory.- Specified by:
cleanUpin interfaceCleanUpHandler
-
-