Class JideScrollPane

All Implemented Interfaces:
JideScrollPaneConstants, ImageObserver, MenuContainer, Serializable, Accessible, ScrollPaneConstants

public class JideScrollPane extends JScrollPane implements JideScrollPaneConstants
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.

Credit: This implementation of scroll bar corner is based on work from Santhosh Kumar - santhosh@in.fiorano.com.

See Also:
  • Field Details

  • Constructor Details

    • JideScrollPane

      public JideScrollPane(Component view, int vsbPolicy, int hsbPolicy)
      Creates a JideScrollPane 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, if vsbPolicy is VERTICAL_SCROLLBAR_AS_NEEDED then the vertical scrollbar only appears if the view doesn't fit vertically. The available policy settings are listed at JScrollPane.setVerticalScrollBarPolicy(int) and JScrollPane.setHorizontalScrollBarPolicy(int).
      Parameters:
      view - the component to display in the scrollpanes viewport
      vsbPolicy - an integer that specifies the vertical scrollbar policy
      hsbPolicy - an integer that specifies the horizontal scrollbar policy
      See Also:
    • JideScrollPane

      public JideScrollPane(Component view)
      Creates a JideScrollPane 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 at JScrollPane.setVerticalScrollBarPolicy(int) and JScrollPane.setHorizontalScrollBarPolicy(int).
      Parameters:
      vsbPolicy - an integer that specifies the vertical scrollbar policy
      hsbPolicy - 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

      public void setViewport(JViewport viewport)
      Overrides:
      setViewport in class JScrollPane
    • getRowFooter

      public JViewport getRowFooter()
      Returns the row footer.
      Returns:
      the rowFooter property
      See Also:
    • setRowFooter

      public void setRowFooter(JViewport rowFooter)
      Removes the old rowFooter, if it exists. If the new rowFooter isn't null, syncs the y coordinate of its viewPosition with the viewport (if there is one) and then adds it to the scrollpane.
      Parameters:
      rowFooter - the new row footer to be used; if null the old row footer is still removed and the new rowFooter is set to null
      See Also:
    • setRowHeader

      public void setRowHeader(JViewport rowHeader)
      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 class JScrollPane
      Parameters:
      rowHeader - the new row header
    • setRowFooterView

      public void setRowFooterView(Component view)
      Creates a row-footer viewport if necessary, sets its view and then adds the row-footer viewport to the scrollpane. For example:
       JScrollPane scrollpane = new JideScrollPane();
       scrollpane.setViewportView(myBigComponentToScroll);
       scrollpane.setRowFooterView(myBigComponentsRowFooter);
       
      Parameters:
      view - the component to display as the row footer
      See Also:
    • getColumnFooter

      public JViewport getColumnFooter()
      Returns the column footer.
      Returns:
      the columnFooter property
      See Also:
    • setColumnFooter

      public void setColumnFooter(JViewport columnFooter)
      Removes the old columnFooter, if it exists. If the new columnFooter isn't null, sync the x coordinate of the its viewPosition with the viewport (if there is one) and then add it to the scrollpane.
      Parameters:
      columnFooter - the new column footer to be used; if null the old column footer is still removed and the new columnFooter is set to null
      See Also:
    • setColumnHeader

      public void setColumnHeader(JViewport columnHeader)
      Overrides to make column header viewport synchronizing with the main viewport.
      Overrides:
      setColumnHeader in class JScrollPane
      Parameters:
      columnHeader - the column header
    • getSubColumnHeader

      public JViewport getSubColumnHeader()
      Returns the sub column header.
      Returns:
      the rowSubColumnHeader property
      See Also:
    • setSubColumnHeader

      public void setSubColumnHeader(JViewport subColumnHeader)
      Removes the old sub column header, if it exists. If the new sub column header isn't null, 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; if null the old sub column header is still removed and the new sub column header is set to null
      See Also:
    • setColumnFooterView

      public void setColumnFooterView(Component view)
      Creates a column-footer viewport if necessary, sets its view, and then adds the column-footer viewport to the scrollpane. For example:
       JScrollPane scrollpane = new JideScrollPane();
       scrollpane.setViewportView(myBigComponentToScroll);
       scrollpane.setColumnFooterView(myBigComponentsColumnFooter);
       
      Parameters:
      view - the component to display as the column footer
      See Also:
    • setSubColumnHeaderView

      public void setSubColumnHeaderView(Component view)
      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

      public Component getCorner(String key)
      Overrides:
      getCorner in class JScrollPane
    • setCorner

      public void setCorner(String key, Component corner)
      Overrides:
      setCorner in class JScrollPane
    • getScrollBarCorner

      public Component getScrollBarCorner(String key)
      Parameters:
      key - one of the values as shown above
      Returns:
      one of the components listed below or null if key is invalid:
      • lowerLeft
      • lowerRight
      • upperLeft
      • upperRight
      See Also:
    • setScrollBarCorner

      public void setScrollBarCorner(String key, Component corner)
      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:

      Although "corner" doesn't match any beans property signature, PropertyChange events are generated with the property name set to the corner key.

      Parameters:
      key - identifies which corner the component will appear in
      corner - one of the following components:
      • lowerLeft
      • lowerRight
      • upperLeft
      • upperRight
      Throws:
      IllegalArgumentException - if corner key is invalid
    • updateUI

      public void updateUI()
      Overrides:
      updateUI in class JScrollPane
    • setLayout

      public void setLayout(LayoutManager layout)
      Overrides:
      setLayout in class JScrollPane
    • 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.
    • isColumnFootersHeightUnified

      public boolean isColumnFootersHeightUnified()
      If true, the bottom-right, bottom-left corners the column footer will have the same height. If false, three of them will keep their own preferred height.
      Returns:
      true or false.
    • setColumnFootersHeightUnified

      public 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.
      Parameters:
      columnFootersHeightUnified - 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 is HORIZONTAL_SCROLLBAR_AS_NEEDED or VERTICAL_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