freaklamarsch.awt
Class FLMScrollPane

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.ScrollPane
                    |
                    +--freaklamarsch.awt.FLMScrollPane
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
CheckboxScrollPane

public class FLMScrollPane
extends java.awt.ScrollPane

FLMScrollPane subclasses ScrollPane and adds some bugfixes, workaraounds and new behaviour.

Author:
FReAK La Marsch
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.awt.ScrollPane
java.awt.ScrollPane.AccessibleAWTScrollPane
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int CENTER_BOTH
           
static int CENTER_HORIZONTAL
           
static int CENTER_NONE
           
static int CENTER_VERTICAL
           
static int EAST_BOTH
           
static int EAST_HORIZONTAL
           
static int EAST_NONE
           
static int EAST_VERTICAL
           
static int NORTH_BOTH
           
static int NORTH_HORIZONTAL
           
static int NORTH_NONE
           
static int NORTH_VERTICAL
           
static int NORTHEAST_BOTH
           
static int NORTHEAST_HORIZONTAL
           
static int NORTHEAST_NONE
           
static int NORTHEAST_VERTICAL
           
static int NORTHWEST_BOTH
           
static int NORTHWEST_HORIZONTAL
           
static int NORTHWEST_NONE
           
static int NORTHWEST_VERTICAL
           
static int SOUTH_BOTH
           
static int SOUTH_HORIZONTAL
           
static int SOUTH_NONE
           
static int SOUTH_VERTICAL
           
static int SOUTHEAST_BOTH
           
static int SOUTHEAST_HORIZONTAL
           
static int SOUTHEAST_NONE
           
static int SOUTHEAST_VERTICAL
           
static int SOUTHWEST_BOTH
           
static int SOUTHWEST_HORIZONTAL
           
static int SOUTHWEST_NONE
           
static int SOUTHWEST_VERTICAL
           
static int WEST_BOTH
           
static int WEST_HORIZONTAL
           
static int WEST_NONE
           
static int WEST_VERTICAL
           
 
Fields inherited from class java.awt.ScrollPane
SCROLLBARS_ALWAYS, SCROLLBARS_AS_NEEDED, SCROLLBARS_NEVER
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
FLMScrollPane()
          Create a new scrollpane container with a scrollbar display policy of "as needed".
FLMScrollPane(int scrollbarDisplayPolicy)
          Create a new scrollpane container with a given scrollbar display policy
FLMScrollPane(int scrollbarDisplayPolicy, int fill)
          Create a new scrollpane container.
 
Method Summary
 java.awt.Component addComponent(java.awt.Component comp)
          Adds the specified component to the end of this FLMScrollPane's contentPanel.
 java.awt.Component addComponent(java.awt.Component comp, int index)
          Adds the specified component to the end of this FLMScrollPane's contentPanel at the given position.
 void addComponent(java.awt.Component comp, java.lang.Object constraints)
          Adds the specified component to the end of this FLMScrollPane's contentPanel.
 void addComponent(java.awt.Component comp, java.lang.Object constraints, int index)
          Adds the specified component to this FLMScrollPane's contentPanel with the specified constraints at the specified index.
 java.awt.Component addComponent(java.lang.String name, java.awt.Component comp)
          Adds the specified component to the end of this FLMScrollPane's contentPanel.
 java.awt.Panel getContentPanel()
          Workaround for a Bug when Scrolbars are only displayed when needed.
 void removeAllComponents()
          Removes all the components from this FLMScrollPane's contentPanel.
 void removeComponent(java.awt.Component comp)
          Removes the specified component from this FLMScrollPane's contentPanel.
 void removeComponentAt(int index)
          Removes the component, specified by index, from this FLMScrollPane's contentPanel.
 void replaceContent(java.awt.Component comp)
          Adds the specified component to this FLMScrollPane's contentPanel.
 
Methods inherited from class java.awt.ScrollPane
addImpl, addNotify, doLayout, eventTypeEnabled, getAccessibleContext, getHAdjustable, getHScrollbarHeight, getScrollbarDisplayPolicy, getScrollPosition, getVAdjustable, getViewportSize, getVScrollbarWidth, isWheelScrollingEnabled, layout, paramString, printComponents, processMouseWheelEvent, setLayout, setScrollPosition, setScrollPosition, setWheelScrollingEnabled
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, transferFocusBackward, transferFocusDownCycle, update, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CENTER_NONE

public static final int CENTER_NONE
See Also:
Constant Field Values

CENTER_BOTH

public static final int CENTER_BOTH
See Also:
Constant Field Values

CENTER_HORIZONTAL

public static final int CENTER_HORIZONTAL
See Also:
Constant Field Values

CENTER_VERTICAL

public static final int CENTER_VERTICAL
See Also:
Constant Field Values

NORTH_NONE

public static final int NORTH_NONE
See Also:
Constant Field Values

NORTH_BOTH

public static final int NORTH_BOTH
See Also:
Constant Field Values

NORTH_HORIZONTAL

public static final int NORTH_HORIZONTAL
See Also:
Constant Field Values

NORTH_VERTICAL

public static final int NORTH_VERTICAL
See Also:
Constant Field Values

NORTHEAST_NONE

public static final int NORTHEAST_NONE
See Also:
Constant Field Values

NORTHEAST_BOTH

public static final int NORTHEAST_BOTH
See Also:
Constant Field Values

NORTHEAST_HORIZONTAL

public static final int NORTHEAST_HORIZONTAL
See Also:
Constant Field Values

NORTHEAST_VERTICAL

public static final int NORTHEAST_VERTICAL
See Also:
Constant Field Values

EAST_NONE

public static final int EAST_NONE
See Also:
Constant Field Values

EAST_BOTH

public static final int EAST_BOTH
See Also:
Constant Field Values

EAST_HORIZONTAL

public static final int EAST_HORIZONTAL
See Also:
Constant Field Values

EAST_VERTICAL

public static final int EAST_VERTICAL
See Also:
Constant Field Values

SOUTHEAST_NONE

public static final int SOUTHEAST_NONE
See Also:
Constant Field Values

SOUTHEAST_BOTH

public static final int SOUTHEAST_BOTH
See Also:
Constant Field Values

SOUTHEAST_HORIZONTAL

public static final int SOUTHEAST_HORIZONTAL
See Also:
Constant Field Values

SOUTHEAST_VERTICAL

public static final int SOUTHEAST_VERTICAL
See Also:
Constant Field Values

SOUTH_NONE

public static final int SOUTH_NONE
See Also:
Constant Field Values

SOUTH_BOTH

public static final int SOUTH_BOTH
See Also:
Constant Field Values

SOUTH_HORIZONTAL

public static final int SOUTH_HORIZONTAL
See Also:
Constant Field Values

SOUTH_VERTICAL

public static final int SOUTH_VERTICAL
See Also:
Constant Field Values

SOUTHWEST_NONE

public static final int SOUTHWEST_NONE
See Also:
Constant Field Values

SOUTHWEST_BOTH

public static final int SOUTHWEST_BOTH
See Also:
Constant Field Values

SOUTHWEST_HORIZONTAL

public static final int SOUTHWEST_HORIZONTAL
See Also:
Constant Field Values

SOUTHWEST_VERTICAL

public static final int SOUTHWEST_VERTICAL
See Also:
Constant Field Values

WEST_NONE

public static final int WEST_NONE
See Also:
Constant Field Values

WEST_BOTH

public static final int WEST_BOTH
See Also:
Constant Field Values

WEST_HORIZONTAL

public static final int WEST_HORIZONTAL
See Also:
Constant Field Values

WEST_VERTICAL

public static final int WEST_VERTICAL
See Also:
Constant Field Values

NORTHWEST_NONE

public static final int NORTHWEST_NONE
See Also:
Constant Field Values

NORTHWEST_BOTH

public static final int NORTHWEST_BOTH
See Also:
Constant Field Values

NORTHWEST_HORIZONTAL

public static final int NORTHWEST_HORIZONTAL
See Also:
Constant Field Values

NORTHWEST_VERTICAL

public static final int NORTHWEST_VERTICAL
See Also:
Constant Field Values
Constructor Detail

FLMScrollPane

public FLMScrollPane()
Create a new scrollpane container with a scrollbar display policy of "as needed".


FLMScrollPane

public FLMScrollPane(int scrollbarDisplayPolicy)
Create a new scrollpane container with a given scrollbar display policy

Parameters:
scrollbarDisplayPolicy - policy for when scrollbars should be shown

FLMScrollPane

public FLMScrollPane(int scrollbarDisplayPolicy,
                     int fill)
Create a new scrollpane container.

Parameters:
fill - policy for how the content should be resized in the contentPanel
scrollbarDisplayPolicy - policy for when scrollbars should be shown
Method Detail

addComponent

public java.awt.Component addComponent(java.awt.Component comp)
Adds the specified component to the end of this FLMScrollPane's contentPanel.

Parameters:
comp - the component to be added.
Returns:
the component argument.

addComponent

public java.awt.Component addComponent(java.lang.String name,
                                       java.awt.Component comp)
Adds the specified component to the end of this FLMScrollPane's contentPanel. It is strongly advised to use the 1.1 method, add(Component, Object), in place of this method.


addComponent

public java.awt.Component addComponent(java.awt.Component comp,
                                       int index)
Adds the specified component to the end of this FLMScrollPane's contentPanel at the given position.

Parameters:
comp - the component to be added.
index - the position at which to insert the component, or -1 to insert the component at the end.
Returns:
the component comp

addComponent

public void addComponent(java.awt.Component comp,
                         java.lang.Object constraints)
Adds the specified component to the end of this FLMScrollPane's contentPanel. Also notifies the contentPanel's LayoutManager to add the component to the contentPanel's layout using the specified constraints object.

Parameters:
comp - the component to be added
constraints - an object expressing layout contraints for this component

addComponent

public void addComponent(java.awt.Component comp,
                         java.lang.Object constraints,
                         int index)
Adds the specified component to this FLMScrollPane's contentPanel with the specified constraints at the specified index. Also notifies the layout manager to add the component to the this contentPanel's layout using the specified constraints object.

Parameters:
comp - the component to be added
constraints - an object expressing layout contraints for this
index - the position in the container's list at which to insert the component. -1 means insert at the end.

replaceContent

public void replaceContent(java.awt.Component comp)
Adds the specified component to this FLMScrollPane's contentPanel. If the contentPanel has an existing child component, that component is removed and the new one is added.

Parameters:
comp - the component to be added

removeComponentAt

public void removeComponentAt(int index)
Removes the component, specified by index, from this FLMScrollPane's contentPanel.

Parameters:
index - the index of the component to be removed.
See Also:
Container.add(java.awt.Component)

removeComponent

public void removeComponent(java.awt.Component comp)
Removes the specified component from this FLMScrollPane's contentPanel.

Parameters:
comp - contentPanel to be removed

removeAllComponents

public void removeAllComponents()
Removes all the components from this FLMScrollPane's contentPanel.


getContentPanel

public java.awt.Panel getContentPanel()
Workaround for a Bug when Scrolbars are only displayed when needed. When the horizontal Scrollbar was shown, it hid a part of the Viewport private void adjustComponentsSize(Component c) { System.out.println(Math.max(getHScrollbarHeight(),16)); System.out.println(super.getPreferredSize()); Dimension componentsPreferredSize = c.getPreferredSize(); System.out.println((componentsPreferredSize.height > (getViewportSize().height - getInsets().top * 2)) ? new Dimension(componentsPreferredSize.width, componentsPreferredSize.height + Math.max(getHScrollbarHeight(),16)) : componentsPreferredSize); //checks if the horizontal Scrollbar is displayed(this is when the panel is higher than the ScrollPane height - insets) c.setSize( (componentsPreferredSize.height > (getViewportSize().height - getInsets().top * 2)) ? new Dimension(componentsPreferredSize.width, componentsPreferredSize.height + Math.max(getHScrollbarHeight(),16)) : componentsPreferredSize);//if scrollbar is displayed, but a height of 0 is returned }