ScrollPane is not scrolling! [message #221273] |
Fri, 11 August 2006 09:12 |
Eclipse User |
|
|
|
Originally posted by: zouzhile.gmail.com
Hi, I am trying out a ScrollPane. My draw2D diagrams has a top figure
which simply serves as a container to add other figures. The top figure
is then composed of two figures: one is a scrollpane. which is used to
hold some small figures serving as items; the other figure is used to
shown the detail of the selected item figure in the scrollpane. it's
something like the picture below:
--------------------------------------------
| |
| -------- ------------------------ |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| -------- ------------------------- |
| |
--------------------------------------------
and the code is concerned with the scrollpane and top figure is this:
public class TopContainerFigure extends FreeformLayeredPane
{
public TopContainerFigure()
{
super();
this.setLayoutManager(new FreeformLayout());
this.setBackgroundColor(ColorConstants.white);
this.setOpaque(true);
ScrollPane scrollPane= new ScrollPane();
scrollPane.setBounds(new Rectangle(10,10, 120,9*60+10*7));
this.buildDiagram(scrollPane);
ScrollBar scrollBar= new ScrollBar();
scrollBar.setHorizontal(false);
scrollPane.setVerticalScrollBar(scrollBar);
this.add(scrollPane);
}
private void buildDiagram(ScrollPane scrollPane)
{
for(int i=0; i<20; i++)
{
PluginPointItemFigure figure= new PluginPointItemFigure(null);
figure.setBounds(new Rectangle(10,10*(i+1)+i*60,120,60));
scrollPane.getViewport().add(figure);
// scrollPane.add(figure) also not work
}
}
you see, i added 20 figures to the viewport, and only eight and a half
figures can be displayed and the scroll bar just didn't appear. So
what's wrong?
any idea?
Best Regards
Robin
|
|
|
Powered by
FUDForum. Page generated in 0.03292 seconds