Package com.jidesoft.swing
Class JideScrollPane
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JScrollPane
com.jidesoft.swing.JideScrollPane
- All Implemented Interfaces:
JideScrollPaneConstants
,ImageObserver
,MenuContainer
,Serializable
,Accessible
,ScrollPaneConstants
JideScrollPane
is an enhanced version of JScrollPane
. In JScrollPane
, you can
have rowHeader and columnHeader. However you can't have rowFooter and columnFooter. However rowFooter and
columnFooter are very useful in table. For example they can be used to display "total" or "summary" type of
information.
Several methods related to rowFooter and columnFooter are added such as setRowFooter(javax.swing.JViewport)
,
and setColumnFooter(javax.swing.JViewport)
which will set the viewport to rowFooter and columnFooter area
respectively. The usage of those methods are exactly the same as JScrollPane.setRowHeader(javax.swing.JViewport)
.
To fully leverage the power of JideScrollPane, we also create a class called TableScrollPane
which is
part of JIDE Grids package. It will allow you to easily create table with row header, row footer and column footer.
JideScrollPane
also provides support for scrollbar corners. You can set them using setScrollBarCorner(String, java.awt.Component)
. Available key for scroll bar corner is defined at JideScrollPaneConstants
which can be access from JideScrollPane
.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JScrollPane
JScrollPane.AccessibleJScrollPane, JScrollPane.ScrollBar
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
FieldsModifier and TypeFieldDescriptionprotected JViewport
The column footer child.protected Component
The component to the left of horizontal scroll bar.protected Component
The component to the right of horizontal scroll bar.protected JViewport
The row footer child.protected JViewport
The component under column header.protected Component
The component under upper left corner.protected Component
The component under upper right corner.protected Component
The component to the bottom of vertical scroll bar.protected Component
The component to the top of vertical scroll bar.static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
Fields inherited from class javax.swing.JScrollPane
columnHeader, horizontalScrollBar, horizontalScrollBarPolicy, lowerLeft, lowerRight, rowHeader, upperLeft, upperRight, verticalScrollBar, verticalScrollBarPolicy, viewport
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 com.jidesoft.swing.JideScrollPaneConstants
COLUMN_FOOTER, HORIZONTAL_LEADING, HORIZONTAL_LEFT, HORIZONTAL_RIGHT, HORIZONTAL_TRAILING, ROW_FOOTER, SUB_COLUMN_HEADER, SUB_UPPER_LEFT, SUB_UPPER_RIGHT, VERTICAL_BOTTOM, VERTICAL_TOP
Fields inherited from interface javax.swing.ScrollPaneConstants
COLUMN_HEADER, HORIZONTAL_SCROLLBAR, HORIZONTAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER, HORIZONTAL_SCROLLBAR_POLICY, LOWER_LEADING_CORNER, LOWER_LEFT_CORNER, LOWER_RIGHT_CORNER, LOWER_TRAILING_CORNER, ROW_HEADER, UPPER_LEADING_CORNER, UPPER_LEFT_CORNER, UPPER_RIGHT_CORNER, UPPER_TRAILING_CORNER, VERTICAL_SCROLLBAR, VERTICAL_SCROLLBAR_ALWAYS, VERTICAL_SCROLLBAR_AS_NEEDED, VERTICAL_SCROLLBAR_NEVER, VERTICAL_SCROLLBAR_POLICY, VIEWPORT
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty (no viewport view)JideScrollPane
where both horizontal and vertical scrollbars appear when needed.JideScrollPane
(int vsbPolicy, int hsbPolicy) Creates an empty (no viewport view)JideScrollPane
with specified scrollbar policies.JideScrollPane
(Component view) Creates aJideScrollPane
that displays the contents of the specified component, where both horizontal and vertical scrollbars appear whenever the component's contents are larger than the view.JideScrollPane
(Component view, int vsbPolicy, int hsbPolicy) Creates aJideScrollPane
that displays the view component in a viewport whose view position can be controlled with a pair of scrollbars. -
Method Summary
Modifier and TypeMethodDescriptionReturns the column footer.Returns the row footer.getScrollBarCorner
(String key) Returns the component at the specified scroll bar corner.Returns the sub column header.boolean
If true, the bottom-right, bottom-left corners the column footer will have the same height.boolean
If true, the top-right, top-left corners the column header will have the same height.boolean
Gets the flag indicating if the JideScrollPane will layout its view flat without scroll bars.boolean
boolean
Get the flag indicating if JideScrollPane should keep the corner visible when it has corner components defined even when the scroll bar is not visible.boolean
void
setColumnFooter
(JViewport columnFooter) Removes the old columnFooter, if it exists.void
setColumnFootersHeightUnified
(boolean columnFootersHeightUnified) Sets the flag if the bottom-right, bottom-left corner and the column footer will have the same height or different heights.void
setColumnFooterView
(Component view) Creates a column-footer viewport if necessary, sets its view, and then adds the column-footer viewport to the scrollpane.void
setColumnHeader
(JViewport columnHeader) Overrides to make column header viewport synchronizing with the main viewport.void
setColumnHeadersHeightUnified
(boolean columnHeadersHeightUnified) Sets the flag if the top-right, top-left corner and the column header will have the same height or different heights.void
void
setFlatLayout
(boolean flatLayout) Sets the flag indicating if the JideScrollPane will layout its view flat without scroll bars.void
setHorizontalScrollBarCoversWholeWidth
(boolean horizontalScrollBarCoversWholeWidth) void
setKeepCornerVisible
(boolean keepCornerVisible) Set the flag indicating if JideScrollPane should keep the corner visible when it has corner components defined even when the scroll bar is not visible.void
setLayout
(LayoutManager layout) void
setRowFooter
(JViewport rowFooter) Removes the old rowFooter, if it exists.void
setRowFooterView
(Component view) Creates a row-footer viewport if necessary, sets its view and then adds the row-footer viewport to the scrollpane.void
setRowHeader
(JViewport rowHeader) Override setRowHeader method in JScrollPane and synchronize the view with the main viewport.void
setScrollBarCorner
(String key, Component corner) Adds a child that will appear in one of the scroll bars corners.void
setSubColumnHeader
(JViewport subColumnHeader) Removes the old sub column header, if it exists.void
Creates a sub-column-header viewport if necessary, sets its view, and then adds the sub-column-header viewport to the scrollpane.void
setVerticalScrollBarCoversWholeHeight
(boolean verticalScrollBarCoversWholeHeight) void
setViewport
(JViewport viewport) void
updateUI()
Methods inherited from class javax.swing.JScrollPane
createHorizontalScrollBar, createVerticalScrollBar, createViewport, getAccessibleContext, getColumnHeader, getHorizontalScrollBar, getHorizontalScrollBarPolicy, getRowHeader, getUI, getUIClassID, getVerticalScrollBar, getVerticalScrollBarPolicy, getViewport, getViewportBorder, getViewportBorderBounds, isValidateRoot, isWheelScrollingEnabled, paramString, setColumnHeaderView, setComponentOrientation, setHorizontalScrollBar, setHorizontalScrollBarPolicy, setRowHeaderView, setUI, setVerticalScrollBar, setVerticalScrollBarPolicy, setViewportBorder, setViewportView, setWheelScrollingEnabled
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, 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
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, 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, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
_subColumnHeader
The component under column header. Default isnull
.- See Also:
-
_subUpperLeft
The component under upper left corner. Default isnull
.- See Also:
-
_subUpperRight
The component under upper right corner. Default isnull
.- See Also:
-
_hLeft
The component to the left of horizontal scroll bar. -
_hRight
The component to the right of horizontal scroll bar. -
_vTop
The component to the top of vertical scroll bar. -
_vBottom
The component to the bottom of vertical scroll bar. -
PROPERTY_HORIZONTAL_SCROLL_BAR_COVERS_WHOLE_WIDTH
- See Also:
-
PROPERTY_VERTICAL_SCROLL_BAR_COVERS_WHOLE_HEIGHT
- See Also:
-
PROPERTY_KEEP_CORNER_VISIBLE
- See Also:
-
PROPERTY_FLAT_LAYOUT
- See Also:
-
PROPERTY_COLUMN_HEADERS_HEIGHT_UNIFIED
- See Also:
-
PROPERTY_COLUMN_FOOTERS_HEIGHT_UNIFIED
- See Also:
-
CLIENT_PROPERTY_SLAVE_VIEWPORT
- See Also:
-
CLIENT_PROPERTY_MASTER_VIEWPORT
- See Also:
-
Constructor Details
-
JideScrollPane
Creates aJideScrollPane
that displays the view component in a viewport whose view position can be controlled with a pair of scrollbars. The scrollbar policies specify when the scrollbars are displayed, For example, ifvsbPolicy
isVERTICAL_SCROLLBAR_AS_NEEDED
then the vertical scrollbar only appears if the view doesn't fit vertically. The available policy settings are listed atJScrollPane.setVerticalScrollBarPolicy(int)
andJScrollPane.setHorizontalScrollBarPolicy(int)
.- Parameters:
view
- the component to display in the scrollpanes viewportvsbPolicy
- an integer that specifies the vertical scrollbar policyhsbPolicy
- an integer that specifies the horizontal scrollbar policy- See Also:
-
JideScrollPane
Creates aJideScrollPane
that displays the contents of the specified component, where both horizontal and vertical scrollbars appear whenever the component's contents are larger than the view.- Parameters:
view
- the component to display in the scrollpane's viewport- See Also:
-
JideScrollPane
public JideScrollPane(int vsbPolicy, int hsbPolicy) Creates an empty (no viewport view)JideScrollPane
with specified scrollbar policies. The available policy settings are listed atJScrollPane.setVerticalScrollBarPolicy(int)
andJScrollPane.setHorizontalScrollBarPolicy(int)
.- Parameters:
vsbPolicy
- an integer that specifies the vertical scrollbar policyhsbPolicy
- an integer that specifies the horizontal scrollbar policy- See Also:
-
JideScrollPane
public JideScrollPane()Creates an empty (no viewport view)JideScrollPane
where both horizontal and vertical scrollbars appear when needed.
-
-
Method Details
-
setViewport
- Overrides:
setViewport
in classJScrollPane
-
setRowHeader
Override setRowHeader method in JScrollPane and synchronize the view with the main viewport. Swing tried to implement this feature but it will break if the view position changes starts from rowHeader.- Overrides:
setRowHeader
in classJScrollPane
- Parameters:
rowHeader
- the new row header
-
setColumnHeader
Overrides to make column header viewport synchronizing with the main viewport.- Overrides:
setColumnHeader
in classJScrollPane
- Parameters:
columnHeader
- the column header
-
getSubColumnHeader
Returns the sub column header.- Returns:
- the
rowSubColumnHeader
property - See Also:
-
setSubColumnHeader
Removes the old sub column header, if it exists. If the new sub column header isn'tnull
, sync the x coordinate of the its viewPosition with the viewport (if there is one) and then add it to the scroll pane.- Parameters:
subColumnHeader
- the new sub column header to be used; ifnull
the old sub column header is still removed and the new sub column header is set tonull
- See Also:
-
setSubColumnHeaderView
Creates a sub-column-header viewport if necessary, sets its view, and then adds the sub-column-header viewport to the scrollpane.- Parameters:
view
- the component to display as the sub column header- See Also:
-
getCorner
- Overrides:
getCorner
in classJScrollPane
-
setCorner
- Overrides:
setCorner
in classJScrollPane
-
getScrollBarCorner
Returns the component at the specified scroll bar corner. Thekey
value specifying the corner is one of:- Parameters:
key
- one of the values as shown above- Returns:
- one of the components listed below or
null
ifkey
is invalid:- lowerLeft
- lowerRight
- upperLeft
- upperRight
- See Also:
-
setScrollBarCorner
Adds a child that will appear in one of the scroll bars corners. Scroll bar will make room to show the corner component. Legal values for the key are:JideScrollPaneConstants.HORIZONTAL_LEFT
JideScrollPaneConstants.HORIZONTAL_RIGHT
JideScrollPaneConstants.VERTICAL_TOP
JideScrollPaneConstants.VERTICAL_BOTTOM
JideScrollPaneConstants.HORIZONTAL_LEADING
JideScrollPaneConstants.HORIZONTAL_TRAILING
PropertyChange
events are generated with the property name set to the corner key.- Parameters:
key
- identifies which corner the component will appear incorner
- one of the following components:- lowerLeft
- lowerRight
- upperLeft
- upperRight
- Throws:
IllegalArgumentException
- if corner key is invalid
-
updateUI
public void updateUI()- Overrides:
updateUI
in classJScrollPane
-
setLayout
- Overrides:
setLayout
in classJScrollPane
-
isVerticalScrollBarCoversWholeHeight
public boolean isVerticalScrollBarCoversWholeHeight() -
setHorizontalScrollBarCoversWholeWidth
public void setHorizontalScrollBarCoversWholeWidth(boolean horizontalScrollBarCoversWholeWidth) -
isHorizontalScrollBarCoversWholeWidth
public boolean isHorizontalScrollBarCoversWholeWidth() -
setVerticalScrollBarCoversWholeHeight
public void setVerticalScrollBarCoversWholeHeight(boolean verticalScrollBarCoversWholeHeight) -
isColumnHeadersHeightUnified
public boolean isColumnHeadersHeightUnified()If true, the top-right, top-left corners the column header will have the same height. If false, three of them will keep their own preferred height.- Returns:
- true or false.
-
setColumnHeadersHeightUnified
public void setColumnHeadersHeightUnified(boolean columnHeadersHeightUnified) Sets the flag if the top-right, top-left corner and the column header will have the same height or different heights.- Parameters:
columnHeadersHeightUnified
- true or false.
-
isKeepCornerVisible
public boolean isKeepCornerVisible()Get the flag indicating if JideScrollPane should keep the corner visible when it has corner components defined even when the scroll bar is not visible. This flag will take effect only when the scroll bar policy isHORIZONTAL_SCROLLBAR_AS_NEEDED
orVERTICAL_SCROLLBAR_AS_NEEDED
The default value of this flag is false.- Returns:
- the flag.
-
setKeepCornerVisible
public void setKeepCornerVisible(boolean keepCornerVisible) Set the flag indicating if JideScrollPane should keep the corner visible when it has corner components defined even when the scroll bar is not visible.- Parameters:
keepCornerVisible
- the flag
-
isFlatLayout
public boolean isFlatLayout()Gets the flag indicating if the JideScrollPane will layout its view flat without scroll bars.- Returns:
- true if flat layout. Otherwise false.
- Since:
- 3.3.3
- See Also:
-
setFlatLayout
public void setFlatLayout(boolean flatLayout) Sets the flag indicating if the JideScrollPane will layout its view flat without scroll bars. By default, the value is false to keep normal behavior.- Parameters:
flatLayout
- the flag- Since:
- 3.3.3
-