Class ScrollablePanel
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- org.processmining.servicelevelagreements.util.ScrollablePanel
-
- All Implemented Interfaces:
java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,javax.accessibility.Accessible,javax.swing.Scrollable,javax.swing.SwingConstants
public class ScrollablePanel extends javax.swing.JPanel implements javax.swing.Scrollable, javax.swing.SwingConstantsA panel that implements the Scrollable interface. This class allows you to customize the scrollable features by using newly provided setter methods so you don't have to extend this class every time. Scrollable amounts can be specifed as a percentage of the viewport size or as an actual pixel value. The amount can be changed for both unit and block scrolling for both horizontal and vertical scrollbars. The Scrollable interface only provides a boolean value for determining whether or not the viewport size (width or height) should be used by the scrollpane when determining if scrollbars should be made visible. This class supports the concept of dynamically changing this value based on the size of the viewport. In this case the viewport size will only be used when it is larger than the panels size. This has the effect of ensuring the viewport is always full as components added to the panel will be size to fill the area available, based on the rules of the applicable layout manager of course. {@link https://tips4java.wordpress.com/2009/12/20/scrollable-panel/} {@link http://stackoverflow.com/questions/5174070/wrapping-html-text-in-a-jeditorpane-inside-a-jscrollpane}- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classScrollablePanel.IncrementTypestatic classScrollablePanel.ScrollableSizeHint-
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
-
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
-
-
Constructor Summary
Constructors Constructor Description ScrollablePanel()Default constructor that uses a FlowLayoutScrollablePanel(java.awt.LayoutManager layout)Constuctor for specifying the LayoutManager of the panel.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.DimensiongetPreferredScrollableViewportSize()org.processmining.servicelevelagreements.util.ScrollablePanel.IncrementInfogetScrollableBlockIncrement(int orientation)Get the block IncrementInfo for the specified orientationintgetScrollableBlockIncrement(java.awt.Rectangle visible, int orientation, int direction)ScrollablePanel.ScrollableSizeHintgetScrollableHeight()Get the height ScrollableSizeHint enumprotected intgetScrollableIncrement(org.processmining.servicelevelagreements.util.ScrollablePanel.IncrementInfo info, int distance)booleangetScrollableTracksViewportHeight()booleangetScrollableTracksViewportWidth()org.processmining.servicelevelagreements.util.ScrollablePanel.IncrementInfogetScrollableUnitIncrement(int orientation)Get the unit IncrementInfo for the specified orientationintgetScrollableUnitIncrement(java.awt.Rectangle visible, int orientation, int direction)ScrollablePanel.ScrollableSizeHintgetScrollableWidth()Get the width ScrollableSizeHint enumvoidsetScrollableBlockIncrement(int orientation, org.processmining.servicelevelagreements.util.ScrollablePanel.IncrementInfo info)Specify the information needed to do block scrolling.voidsetScrollableBlockIncrement(int orientation, ScrollablePanel.IncrementType type, int amount)Specify the information needed to do block scrolling.voidsetScrollableHeight(ScrollablePanel.ScrollableSizeHint scrollableHeight)Set the ScrollableSizeHint enum for the height.voidsetScrollableUnitIncrement(int orientation, org.processmining.servicelevelagreements.util.ScrollablePanel.IncrementInfo info)Specify the information needed to do unit scrolling.voidsetScrollableUnitIncrement(int orientation, ScrollablePanel.IncrementType type, int amount)Specify the information needed to do unit scrolling.voidsetScrollableWidth(ScrollablePanel.ScrollableSizeHint scrollableWidth)Set the ScrollableSizeHint enum for the width.-
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, 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, 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
-
-
-
-
Method Detail
-
getScrollableHeight
public ScrollablePanel.ScrollableSizeHint getScrollableHeight()
Get the height ScrollableSizeHint enum- Returns:
- the ScrollableSizeHint enum for the height
-
setScrollableHeight
public void setScrollableHeight(ScrollablePanel.ScrollableSizeHint scrollableHeight)
Set the ScrollableSizeHint enum for the height. The enum is used to determine the boolean value that is returned by the getScrollableTracksViewportHeight() method. The valid values are: ScrollableSizeHint.NONE - return "false", which causes the height of the panel to be used when laying out the children ScrollableSizeHint.FIT - return "true", which causes the height of the viewport to be used when laying out the children ScrollableSizeHint.STRETCH - return "true" when the viewport height is greater than the height of the panel, "false" otherwise.- Parameters:
scrollableHeight- as represented by the ScrollableSizeHint enum.
-
getScrollableWidth
public ScrollablePanel.ScrollableSizeHint getScrollableWidth()
Get the width ScrollableSizeHint enum- Returns:
- the ScrollableSizeHint enum for the width
-
setScrollableWidth
public void setScrollableWidth(ScrollablePanel.ScrollableSizeHint scrollableWidth)
Set the ScrollableSizeHint enum for the width. The enum is used to determine the boolean value that is returned by the getScrollableTracksViewportWidth() method. The valid values are: ScrollableSizeHint.NONE - return "false", which causes the width of the panel to be used when laying out the children ScrollableSizeHint.FIT - return "true", which causes the width of the viewport to be used when laying out the children ScrollableSizeHint.STRETCH - return "true" when the viewport width is greater than the width of the panel, "false" otherwise.- Parameters:
scrollableWidth- as represented by the ScrollableSizeHint enum.
-
getScrollableBlockIncrement
public org.processmining.servicelevelagreements.util.ScrollablePanel.IncrementInfo getScrollableBlockIncrement(int orientation)
Get the block IncrementInfo for the specified orientation- Returns:
- the block IncrementInfo for the specified orientation
-
setScrollableBlockIncrement
public void setScrollableBlockIncrement(int orientation, ScrollablePanel.IncrementType type, int amount)Specify the information needed to do block scrolling.- Parameters:
orientation- specify the scrolling orientation. Must be either: SwingContants.HORIZONTAL or SwingContants.VERTICAL.amount- a value used with the IncrementType to determine the scrollable amount
-
setScrollableBlockIncrement
public void setScrollableBlockIncrement(int orientation, org.processmining.servicelevelagreements.util.ScrollablePanel.IncrementInfo info)Specify the information needed to do block scrolling.- Parameters:
orientation- specify the scrolling orientation. Must be either: SwingContants.HORIZONTAL or SwingContants.VERTICAL.info- An IncrementInfo object containing information of how to calculate the scrollable amount.
-
getScrollableUnitIncrement
public org.processmining.servicelevelagreements.util.ScrollablePanel.IncrementInfo getScrollableUnitIncrement(int orientation)
Get the unit IncrementInfo for the specified orientation- Returns:
- the unit IncrementInfo for the specified orientation
-
setScrollableUnitIncrement
public void setScrollableUnitIncrement(int orientation, ScrollablePanel.IncrementType type, int amount)Specify the information needed to do unit scrolling.- Parameters:
orientation- specify the scrolling orientation. Must be either: SwingContants.HORIZONTAL or SwingContants.VERTICAL.amount- a value used with the IncrementType to determine the scrollable amount
-
setScrollableUnitIncrement
public void setScrollableUnitIncrement(int orientation, org.processmining.servicelevelagreements.util.ScrollablePanel.IncrementInfo info)Specify the information needed to do unit scrolling.- Parameters:
orientation- specify the scrolling orientation. Must be either: SwingContants.HORIZONTAL or SwingContants.VERTICAL.info- An IncrementInfo object containing information of how to calculate the scrollable amount.
-
getPreferredScrollableViewportSize
public java.awt.Dimension getPreferredScrollableViewportSize()
- Specified by:
getPreferredScrollableViewportSizein interfacejavax.swing.Scrollable
-
getScrollableUnitIncrement
public int getScrollableUnitIncrement(java.awt.Rectangle visible, int orientation, int direction)- Specified by:
getScrollableUnitIncrementin interfacejavax.swing.Scrollable
-
getScrollableBlockIncrement
public int getScrollableBlockIncrement(java.awt.Rectangle visible, int orientation, int direction)- Specified by:
getScrollableBlockIncrementin interfacejavax.swing.Scrollable
-
getScrollableIncrement
protected int getScrollableIncrement(org.processmining.servicelevelagreements.util.ScrollablePanel.IncrementInfo info, int distance)
-
getScrollableTracksViewportWidth
public boolean getScrollableTracksViewportWidth()
- Specified by:
getScrollableTracksViewportWidthin interfacejavax.swing.Scrollable
-
getScrollableTracksViewportHeight
public boolean getScrollableTracksViewportHeight()
- Specified by:
getScrollableTracksViewportHeightin interfacejavax.swing.Scrollable
-
-