Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   scrollbars and boxes (http://www.velocityreviews.com/forums/t622350-scrollbars-and-boxes.html)

Duane Evenson 06-26-2008 08:34 AM

scrollbars and boxes
 
I'm haveing trouble making my scrollbars work. Inside my scrollpane I have
a horizontal Box full of verticle Box's. Inside this, I'm adding and
removing JLabels. When the components move down past the viewing area, the
scrollbars aren't reacting. Could it be the glue I'm adding, or is it the
preferred and minimum sizes I'm specifying? I've tried these and other
things but am stumped.

Here's a code snippet:

Box[] column = new Box[5];
Dimension prefSize = new Dimension(100, 0);
Dimension minSize = new Dimension(80, 80);

// columns
Box table = new Box(BoxLayout.X_AXIS);
for (int x = 0; x < 5; x++) {
title[x] = new JLabel(columnNames[x]);
column[x] = new Box(BoxLayout.Y_AXIS);
column[x].add(title[x]);
column[x].add(Box.createGlue());
column[x].setPreferredSize(prefSize);
column[x].setMinimumSize(minSize);
column[x].setAlignmentX(Component.CENTER_ALIGNMENT);
table.add(column[x]);
}
ScrollPane output = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
output.add(table);

....
pack();
setLocationRelativeTo(null);
setVisible(true);


In an actionlistener I have this:
column[i].add(new JLabel("" + m[x]));
....
column[0].add(Box.createGlue());
column[1].add(Box.createGlue());
column[2].add(Box.createGlue());
column[3].add(Box.createGlue());
column[4].add(Box.createGlue());
validate();



Duane Evenson 06-26-2008 09:00 AM

Re: scrollbars and boxes
 
On Thu, 26 Jun 2008 08:34:24 +0000, Duane Evenson wrote:

> I'm haveing trouble making my scrollbars work. Inside my scrollpane I have
> a horizontal Box full of verticle Box's. Inside this, I'm adding and
> removing JLabels. When the components move down past the viewing area, the
> scrollbars aren't reacting. Could it be the glue I'm adding, or is it the
> preferred and minimum sizes I'm specifying? I've tried these and other
> things but am stumped.
>
> Here's a code snippet:
>
> Box[] column = new Box[5];
> Dimension prefSize = new Dimension(100, 0);
> Dimension minSize = new Dimension(80, 80);
>
> // columns
> Box table = new Box(BoxLayout.X_AXIS);
> for (int x = 0; x < 5; x++) {
> title[x] = new JLabel(columnNames[x]);
> column[x] = new Box(BoxLayout.Y_AXIS);
> column[x].add(title[x]);
> column[x].add(Box.createGlue());
> column[x].setPreferredSize(prefSize);
> column[x].setMinimumSize(minSize);
> column[x].setAlignmentX(Component.CENTER_ALIGNMENT);
> table.add(column[x]);
> }
> ScrollPane output = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
> output.add(table);
>
> ...
> pack();
> setLocationRelativeTo(null);
> setVisible(true);
>
>
> In an actionlistener I have this:
> column[i].add(new JLabel("" + m[x]));
> ...
> column[0].add(Box.createGlue());
> column[1].add(Box.createGlue());
> column[2].add(Box.createGlue());
> column[3].add(Box.createGlue());
> column[4].add(Box.createGlue());
> validate();


An update;
I've replaced
ScrollPane output = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
output.add(table);
//with
JScrollPane output = new JScrollPane(table);

to no benefit. Still no solution.
JScrollPane



All times are GMT. The time now is 08:00 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.