uk.co.ist.mwt
Class ScrollablePanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--uk.co.ist.mwt.ScrollablePanel
Direct Known Subclasses:
ScrolledPanel

public class ScrollablePanel
extends javax.swing.JPanel
implements java.awt.LayoutManager, ScrollConstants, java.io.Serializable

The ScrollablePanel provides a base mechanism for scrolling components. It is a Panel which lays out its work area child and two scrollbars in an appropriate manner. It can be regarded as the equivalent of a XmScrolledWindow with a scrolling policy of XmAPPLICATION_DEFINED. If you want fuller built-in functionality, you need to use the ScrolledPanel, which is a subclass of this providing the equivalent of the XmAUTOMATIC scrolling policy.

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
protected  java.awt.Scrollbar scrollHorz
          The horizontal scroll bar for this panel
protected  java.awt.Scrollbar scrollVert
          The vertical scroll bar for this panel
protected  java.awt.Component workArea
          The work area child (eg.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, 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
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface uk.co.ist.mwt.ScrollConstants
kEast, kFill, kNorth, kNorthEast, kNorthWest, kSouth, kSouthEast, kSouthWest, kWest
 
Constructor Summary
ScrollablePanel()
          Simple constructor, setting the panel's layout to itself...
 
Method Summary
 void addLayoutComponent(java.lang.String name, java.awt.Component comp)
          Add the specified component with the specified name to the layout.
 int getScrollbarPlacement()
          Getter for scrollbar placement
 java.awt.Scrollbar getScrollHorz()
          Gets the horizontal scroll bar
 java.awt.Scrollbar getScrollVert()
          Gets the vertical scroll bar
 boolean hsbNeeded(java.awt.Dimension pSz)
          Function to determine whether the ScrollablePanel needs a horizontal scroll bar if it's compressed into the parent passed in
 void layoutContainer(java.awt.Container parent)
          Lay out the container in the specified panel.
protected  java.awt.Dimension layoutSize(java.awt.Container parent, boolean minimum)
          Calculate the dimensions, minimum or preferred, for the specified panel given the components in the specified parent container.
 java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
          Calculate the minimum size dimensions for the specified panel given the components in the specified parent container.
 java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
          Calculate the preferred size dimensions for the specified panel given the components in the specified parent container.
 void removeLayoutComponent(java.awt.Component comp)
          Remove the specified component from the layout.
 void setScrollbarPlacement(int newPlacement)
          An accessor method to allow the specification of the point in the container where the scroll bars meet; if the value is invalid the change is ignored.
 void setScrollHorz(java.awt.Scrollbar s)
          Sets the horizontal scroll bar
 void setScrollVert(java.awt.Scrollbar s)
          Sets the vertical scroll bar
protected  void setupWorkArea(java.awt.Container parent)
          Method to set up an internal reference to the work area of the Panel, using the children of the parent container passed in.
protected  java.awt.Dimension sizeOfComponent(java.awt.Component comp, boolean minimum)
          Calculate the dimensions, minimum or preferred, of a given component comp
 boolean vsbNeeded(java.awt.Dimension pSz)
          Function to determine whether the ScrollablePanel needs a vertical scroll bar if it's compressed into the parent passed in
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setCursor, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

scrollVert

protected java.awt.Scrollbar scrollVert
The vertical scroll bar for this panel

scrollHorz

protected java.awt.Scrollbar scrollHorz
The horizontal scroll bar for this panel

workArea

protected java.awt.Component workArea
The work area child (eg. the component which displays whatever this ScrollablePanel is scrolling)
Constructor Detail

ScrollablePanel

public ScrollablePanel()
Simple constructor, setting the panel's layout to itself...
Method Detail

setScrollbarPlacement

public void setScrollbarPlacement(int newPlacement)
An accessor method to allow the specification of the point in the container where the scroll bars meet; if the value is invalid the change is ignored. The panel is only re-laid-out if the new value is different to the old one.
See Also:
ScrollConstants.kSouthEast, ScrollConstants.kSouthWest, ScrollConstants.kNorthEast, ScrollConstants.kNorthWest

getScrollbarPlacement

public int getScrollbarPlacement()
Getter for scrollbar placement
See Also:
setScrollbarPlacement(int)

setScrollVert

public void setScrollVert(java.awt.Scrollbar s)
Sets the vertical scroll bar

getScrollVert

public java.awt.Scrollbar getScrollVert()
Gets the vertical scroll bar

setScrollHorz

public void setScrollHorz(java.awt.Scrollbar s)
Sets the horizontal scroll bar

getScrollHorz

public java.awt.Scrollbar getScrollHorz()
Gets the horizontal scroll bar

addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component comp)
Add the specified component with the specified name to the layout.
Specified by:
addLayoutComponent in interface java.awt.LayoutManager
Parameters:
name - the component name
comp - the component to be added
See Also:
removeLayoutComponent(java.awt.Component)

removeLayoutComponent

public void removeLayoutComponent(java.awt.Component comp)
Remove the specified component from the layout.
Specified by:
removeLayoutComponent in interface java.awt.LayoutManager
Parameters:
comp - the component to be removed
See Also:
addLayoutComponent(java.lang.String, java.awt.Component)

sizeOfComponent

protected java.awt.Dimension sizeOfComponent(java.awt.Component comp,
                                             boolean minimum)
Calculate the dimensions, minimum or preferred, of a given component comp
Parameters:
comp - the commponent to find a size for
minimum - a flag to say whether we want the minimum size
See Also:
layoutSize(java.awt.Container, boolean)

layoutSize

protected java.awt.Dimension layoutSize(java.awt.Container parent,
                                        boolean minimum)
Calculate the dimensions, minimum or preferred, for the specified panel given the components in the specified parent container.
Parameters:
parent - the component to be laid out
minimum - a flag to say whether we're looking for the minimum size
See Also:
minimumLayoutSize(java.awt.Container), preferredLayoutSize(java.awt.Container)

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
Calculate the preferred size dimensions for the specified panel given the components in the specified parent container.
Specified by:
preferredLayoutSize in interface java.awt.LayoutManager
Parameters:
parent - the component to be laid out
See Also:
minimumLayoutSize(java.awt.Container), layoutSize(java.awt.Container, boolean)

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
Calculate the minimum size dimensions for the specified panel given the components in the specified parent container.
Specified by:
minimumLayoutSize in interface java.awt.LayoutManager
Parameters:
parent - the component to be laid out
See Also:
preferredLayoutSize(java.awt.Container), layoutSize(java.awt.Container, boolean)

vsbNeeded

public boolean vsbNeeded(java.awt.Dimension pSz)
Function to determine whether the ScrollablePanel needs a vertical scroll bar if it's compressed into the parent passed in

hsbNeeded

public boolean hsbNeeded(java.awt.Dimension pSz)
Function to determine whether the ScrollablePanel needs a horizontal scroll bar if it's compressed into the parent passed in

layoutContainer

public void layoutContainer(java.awt.Container parent)
Lay out the container in the specified panel.
Specified by:
layoutContainer in interface java.awt.LayoutManager
Parameters:
parent - the component which needs to be laid out

setupWorkArea

protected void setupWorkArea(java.awt.Container parent)
Method to set up an internal reference to the work area of the Panel, using the children of the parent container passed in.
Parameters:
parent - the container wholse children should be searched for and appropriate work area.