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.ScrollBarNested 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 TypeFieldDescriptionprotected JViewportThe column footer child.protected ComponentThe component to the left of horizontal scroll bar.protected ComponentThe component to the right of horizontal scroll bar.protected JViewportThe row footer child.protected JViewportThe component under column header.protected ComponentThe component under upper left corner.protected ComponentThe component under upper right corner.protected ComponentThe component to the bottom of vertical scroll bar.protected ComponentThe component to the top of vertical scroll bar.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class javax.swing.JScrollPane
columnHeader, horizontalScrollBar, horizontalScrollBarPolicy, lowerLeft, lowerRight, rowHeader, upperLeft, upperRight, verticalScrollBar, verticalScrollBarPolicy, viewportFields 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 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_TOPFields 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)JideScrollPanewhere both horizontal and vertical scrollbars appear when needed.JideScrollPane(int vsbPolicy, int hsbPolicy) Creates an empty (no viewport view)JideScrollPanewith specified scrollbar policies.JideScrollPane(Component view) Creates aJideScrollPanethat 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 aJideScrollPanethat 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.booleanIf true, the bottom-right, bottom-left corners the column footer will have the same height.booleanIf true, the top-right, top-left corners the column header will have the same height.booleanGets the flag indicating if the JideScrollPane will layout its view flat without scroll bars.booleanbooleanGet the flag indicating if JideScrollPane should keep the corner visible when it has corner components defined even when the scroll bar is not visible.booleanvoidsetColumnFooter(JViewport columnFooter) Removes the old columnFooter, if it exists.voidsetColumnFootersHeightUnified(boolean columnFootersHeightUnified) Sets the flag if the bottom-right, bottom-left corner and the column footer will have the same height or different heights.voidsetColumnFooterView(Component view) Creates a column-footer viewport if necessary, sets its view, and then adds the column-footer viewport to the scrollpane.voidsetColumnHeader(JViewport columnHeader) Overrides to make column header viewport synchronizing with the main viewport.voidsetColumnHeadersHeightUnified(boolean columnHeadersHeightUnified) Sets the flag if the top-right, top-left corner and the column header will have the same height or different heights.voidvoidsetFlatLayout(boolean flatLayout) Sets the flag indicating if the JideScrollPane will layout its view flat without scroll bars.voidsetHorizontalScrollBarCoversWholeWidth(boolean horizontalScrollBarCoversWholeWidth) voidsetKeepCornerVisible(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.voidsetLayout(LayoutManager layout) voidsetRowFooter(JViewport rowFooter) Removes the old rowFooter, if it exists.voidsetRowFooterView(Component view) Creates a row-footer viewport if necessary, sets its view and then adds the row-footer viewport to the scrollpane.voidsetRowHeader(JViewport rowHeader) Override setRowHeader method in JScrollPane and synchronize the view with the main viewport.voidsetScrollBarCorner(String key, Component corner) Adds a child that will appear in one of the scroll bars corners.voidsetSubColumnHeader(JViewport subColumnHeader) Removes the old sub column header, if it exists.voidCreates a sub-column-header viewport if necessary, sets its view, and then adds the sub-column-header viewport to the scrollpane.voidsetVerticalScrollBarCoversWholeHeight(boolean verticalScrollBarCoversWholeHeight) voidsetViewport(JViewport viewport) voidupdateUI()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, setWheelScrollingEnabledMethods 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, updateMethods 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, 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, 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 aJideScrollPanethat 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, ifvsbPolicyisVERTICAL_SCROLLBAR_AS_NEEDEDthen 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 aJideScrollPanethat 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)JideScrollPanewith 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)JideScrollPanewhere both horizontal and vertical scrollbars appear when needed.
-
-
Method Details
-
setViewport
- Overrides:
setViewportin 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:
setRowHeaderin classJScrollPane- Parameters:
rowHeader- the new row header
-
setColumnHeader
Overrides to make column header viewport synchronizing with the main viewport.- Overrides:
setColumnHeaderin classJScrollPane- Parameters:
columnHeader- the column header
-
getSubColumnHeader
Returns the sub column header.- Returns:
- the
rowSubColumnHeaderproperty - 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; ifnullthe 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:
getCornerin classJScrollPane
-
setCorner
- Overrides:
setCornerin classJScrollPane
-
getScrollBarCorner
Returns the component at the specified scroll bar corner. Thekeyvalue specifying the corner is one of:- Parameters:
key- one of the values as shown above- Returns:
- one of the components listed below or
nullifkeyis 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_LEFTJideScrollPaneConstants.HORIZONTAL_RIGHTJideScrollPaneConstants.VERTICAL_TOPJideScrollPaneConstants.VERTICAL_BOTTOMJideScrollPaneConstants.HORIZONTAL_LEADINGJideScrollPaneConstants.HORIZONTAL_TRAILING
PropertyChangeevents 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:
updateUIin classJScrollPane
-
setLayout
- Overrides:
setLayoutin 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_NEEDEDorVERTICAL_SCROLLBAR_AS_NEEDEDThe 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
-