|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.FlowLayout
org.freehep.swing.layout.FlowScrollLayout
public class FlowScrollLayout
This class is a replacement for a FlowLayout inside a JScrollPane. It can be used as a plain FlowLayout, but it is intended to be used on a container inside a JScrollPane. If it is the layout for a Container that is the view of a JViewport inside a JScrollPane, then it will cause the Container's children to be wrapped so that the JScrollPane only scrolls vertically.
It can optionally resize all children on each row to be as tall as the tallest one. IMHO, this often looks better, but is off by default for compatiblity with FlowLayout.
Note:Each FlowScrollLayout should be used for only one Container.
Bug:The JViewport inside the JScrollPane that you give to FlowScrollLayout must have a child during the whole time that FlowScrollLayout is used with that JScrollPane. (Typically, that child is the widget whose layout is the FlowScrollLayout.) Otherwise FlowScrollLayout will throw a NullPointerException. It should handle this condition gracefully, but I do not have time to fix it right now. If anyone wants to send me a patch, it would be welcome.
This software is distributed under the Berkeley Software License.
| Field Summary |
|---|
| Fields inherited from class java.awt.FlowLayout |
|---|
CENTER, LEADING, LEFT, RIGHT, TRAILING |
| Constructor Summary | |
|---|---|
FlowScrollLayout()
|
|
FlowScrollLayout(JScrollPane scrollPane)
|
|
FlowScrollLayout(JScrollPane scrollPane,
boolean uniformHeight)
|
|
| Method Summary | |
|---|---|
void |
addLayoutComponent(Component comp,
Object constraints)
Adds the specified component to the layout, using the specified constraint object. |
void |
componentHidden(ComponentEvent e)
|
void |
componentMoved(ComponentEvent e)
|
void |
componentResized(ComponentEvent e)
|
void |
componentShown(ComponentEvent e)
|
protected Dimension |
computeDesiredSize()
Follow the layout algorithm that FlowLayout uses to compute how big we would like to be, given the size of the containing JScrollPane. |
float |
getLayoutAlignmentX(Container target)
Returns the alignment along the x axis. |
float |
getLayoutAlignmentY(Container target)
|
void |
invalidateLayout(Container target)
|
boolean |
isUniformHeight()
|
void |
layoutContainer(Container c)
|
Dimension |
maximumLayoutSize(Container target)
Returns the maximum size of this component. |
static void |
setHeights(Container container,
int height,
int startIndex,
int endIndex)
Set the preferred size of all JComponents inside container to have height height, starting at the startIndex'th child and going up to endIndex-1. |
static void |
setPreferredHeight(JComponent comp,
int height)
Set preferredSize of comp to be Dimension(current preferredSize.width, height) |
void |
setScrollPane(JScrollPane scrollPane)
|
void |
setUniformHeight(boolean on)
If uniformHeight is turned on, all widgets on each row will have their preferred height set to the height of the tallest one (based on preferredSize). |
protected void |
updateLayout()
Update the layout of the managed widget and the containing scrollbar (only if the current size doesn't match the desired size) |
| Methods inherited from class java.awt.FlowLayout |
|---|
addLayoutComponent, getAlignment, getHgap, getVgap, minimumLayoutSize, preferredLayoutSize, removeLayoutComponent, setAlignment, setHgap, setVgap, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.awt.LayoutManager |
|---|
addLayoutComponent, minimumLayoutSize, preferredLayoutSize, removeLayoutComponent |
| Constructor Detail |
|---|
public FlowScrollLayout()
public FlowScrollLayout(JScrollPane scrollPane)
public FlowScrollLayout(JScrollPane scrollPane,
boolean uniformHeight)
| Method Detail |
|---|
public void setScrollPane(JScrollPane scrollPane)
public void setUniformHeight(boolean on)
public boolean isUniformHeight()
protected Dimension computeDesiredSize()
public static void setHeights(Container container,
int height,
int startIndex,
int endIndex)
public static void setPreferredHeight(JComponent comp,
int height)
protected void updateLayout()
public void layoutContainer(Container c)
layoutContainer in interface LayoutManagerlayoutContainer in class FlowLayoutpublic void componentResized(ComponentEvent e)
componentResized in interface ComponentListenerpublic void componentMoved(ComponentEvent e)
componentMoved in interface ComponentListenerpublic void componentShown(ComponentEvent e)
componentShown in interface ComponentListenerpublic void componentHidden(ComponentEvent e)
componentHidden in interface ComponentListenerpublic void invalidateLayout(Container target)
invalidateLayout in interface LayoutManager2public float getLayoutAlignmentY(Container target)
getLayoutAlignmentY in interface LayoutManager2public float getLayoutAlignmentX(Container target)
getLayoutAlignmentX in interface LayoutManager2public Dimension maximumLayoutSize(Container target)
maximumLayoutSize in interface LayoutManager2Component.getMinimumSize(),
Component.getPreferredSize(),
LayoutManager
public void addLayoutComponent(Component comp,
Object constraints)
addLayoutComponent in interface LayoutManager2comp - the component to be addedconstraints - where/how the component is added to the layout.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||