scrollbars and boxes

Discussion in 'Java' started by Duane Evenson, Jun 26, 2008.

  1. 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.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, Jun 26, 2008
    #1
    1. Advertisements

  2. 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.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
     
    Duane Evenson, Jun 26, 2008
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TWlrZQ==?=

    CheckBoxList and Scrollbars

    =?Utf-8?B?TWlrZQ==?=, Nov 16, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    801
    =?Utf-8?B?TWlrZQ==?=
    Nov 16, 2004
  2. Blue Streak

    ASP:Panel and Scrollbars...

    Blue Streak, Mar 8, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    3,604
    Blue Streak
    Mar 8, 2005
  3. tshad

    Listbox and Scrollbars

    tshad, Jun 10, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    497
    tshad
    Jun 10, 2005
  4. Bluetears76
    Replies:
    1
    Views:
    1,196
    Larry Barowski
    Jul 1, 2004
  5. Ronny Mandal

    Frames and scrollbars

    Ronny Mandal, Apr 21, 2004, in forum: HTML
    Replies:
    7
    Views:
    554
    Jim Roberts
    Apr 22, 2004
  6. Yereth Jansen

    Off page scrollbars with div and css

    Yereth Jansen, May 9, 2005, in forum: HTML
    Replies:
    16
    Views:
    1,217
    Yereth Jansen
    May 16, 2005
  7. loga123
    Replies:
    9
    Views:
    7,928
    loga123
    Jun 8, 2006
  8. Stefan Mueller
    Replies:
    5
    Views:
    12,977
    jamesxa
    Jun 16, 2009
Loading...