uk.co.ist.mwt
Class ScrolledPanel

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

public class ScrolledPanel
extends ScrollablePanel
implements java.awt.event.AdjustmentListener

The ScrolledPanel provides a mechanism for scrolling components. It can take one child component, and provides two Scrollbars to allow it to be scrolled. It handles all scrolling events from the Scrollbars, sorting out page increments and the like based on its current size.

Children added to this panel are actually added to its clipwindow child, which only displays one of them.

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
 
Fields inherited from class uk.co.ist.mwt.ScrollablePanel
scrollHorz, scrollVert, workArea
 
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
 
Constructor Summary
ScrolledPanel()
          Create a ScrolledPanel with everything set to the default
 
Method Summary
protected  void addImpl(java.awt.Component comp, java.lang.Object constraints, int pos)
          Add a component to the Panel; overriden so that any children added are put into the clipWindow.
 void adjustmentValueChanged(java.awt.event.AdjustmentEvent e)
          A method to catch scrollbar events to handle scrolling
 java.awt.Component getComponentAt(int x, int y)
          Locate a component; as we're hiding the existence of the internal clipWindow, we must return one of its children if the click is inside it.
 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 remove(java.awt.Component comp)
          Remove a component from the panel; overriden so that any children are removed from the clipWindow.
 void removeAll()
          Remove all components from the panel; actually removes those from the clipWindow.
 void setAlwaysShowScrollbars(boolean whether)
          Set whether we should always show the scroll bars for this ScrolledPanel, even if they are not necessary
 void setWorkAreaPlacement(int newPlacement)
          An accessor method to allow the specification of the point in the clip window where the work area is placed if it is smaller than the clip window; if the value is invalid the change is ignored.
 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 uk.co.ist.mwt.ScrollablePanel
addLayoutComponent, getScrollbarPlacement, getScrollHorz, getScrollVert, layoutContainer, layoutSize, minimumLayoutSize, preferredLayoutSize, removeLayoutComponent, setScrollbarPlacement, setScrollHorz, setScrollVert, setupWorkArea, sizeOfComponent
 
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, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, 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
 

Constructor Detail

ScrolledPanel

public ScrolledPanel()
Create a ScrolledPanel with everything set to the default
Method Detail

setAlwaysShowScrollbars

public void setAlwaysShowScrollbars(boolean whether)
Set whether we should always show the scroll bars for this ScrolledPanel, even if they are not necessary

setWorkAreaPlacement

public void setWorkAreaPlacement(int newPlacement)
An accessor method to allow the specification of the point in the clip window where the work area is placed if it is smaller than the clip window; 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, ScrollConstants.kSouth, ScrollConstants.kNorth, ScrollConstants.kEast, ScrollConstants.kWest, ScrollConstants.kFill

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
Overrides:
vsbNeeded in class ScrollablePanel

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
Overrides:
hsbNeeded in class ScrollablePanel

adjustmentValueChanged

public void adjustmentValueChanged(java.awt.event.AdjustmentEvent e)
A method to catch scrollbar events to handle scrolling
Specified by:
adjustmentValueChanged in interface java.awt.event.AdjustmentListener
Parameters:
e - the event

addImpl

protected void addImpl(java.awt.Component comp,
                       java.lang.Object constraints,
                       int pos)
Add a component to the Panel; overriden so that any children added are put into the clipWindow.
Overrides:
addImpl in class java.awt.Container
Parameters:
comp - the component to add
pos - the position in the list of children at which to add it; -1 means 'at the end'.
See Also:
remove(java.awt.Component)

remove

public void remove(java.awt.Component comp)
Remove a component from the panel; overriden so that any children are removed from the clipWindow.
Overrides:
remove in class java.awt.Container
Parameters:
comp - the component to remove
See Also:
Container.add(java.awt.Component)

removeAll

public void removeAll()
Remove all components from the panel; actually removes those from the clipWindow.
Overrides:
removeAll in class java.awt.Container

getComponentAt

public java.awt.Component getComponentAt(int x,
                                         int y)
Locate a component; as we're hiding the existence of the internal clipWindow, we must return one of its children if the click is inside it.
Overrides:
getComponentAt in class java.awt.Container
Parameters:
x - the x co-ordinate within this component which the desired component contains
y - the y co-ordinate within this component which the desired component contains