Can't scroll horizontal scrollbar

Discussion in 'Java' started by Kurt Underhay, Apr 11, 2005.

  1. I've got an app with a GUI that includes a JTable. I'd like for the
    table to be scrollable, so I've created a JScrollPane on it. However,
    the horizontal scrollbar doesn't have a scroll knob on it, and using the
    left/right scroll buttons doesn't cause it to scroll. How can I get the
    horizontal scrolling working?

    Relevant code fragment below.
    -----------------------------------------------

    JFrame frame = new JFrame(title);
    JDesktopPane JDPane = new JDesktopPane();
    frame.getContentPane().add(JDPane);

    JInternalFrame JIFrame1 = new JInternalFrame(title + " JIFrame1");
    JDPane.add(JIFrame1);

    JTable table = new JTable(100,100);
    JIFrame1.getContentPane().add(table);
    table.setVisible(true);

    JScrollPane JSPane = new JScrollPane(table);
    JSPane.setPreferredSize(new Dimension(100,100));

    JSPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    JSPane.getHorizontalScrollBar().setEnabled(true);
    JIFrame1.getContentPane().add(JSPane);

    JIFrame1.setClosable(true);
    JIFrame1.setResizable(true);
    JIFrame1.setSize(200,200);
    JIFrame1.setVisible(true);
    frame.setSize(800,700);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
     
    Kurt Underhay, Apr 11, 2005
    #1
    1. Advertising

  2. Kurt Underhay

    Guest

    Check out the method setAutoResizeMode on JTable. I believe that the
    default behavior of a JTable is to resize itself to the viewable area.
    If you set it to AUTO_RESIZE_OFF, you will probably see the scroll bar.
     
    , Apr 11, 2005
    #2
    1. Advertising

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. Marco Liedekerken

    Panel with horizontal scrollbar

    Marco Liedekerken, Jun 26, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    5,958
    Rajesh.V
    Jun 26, 2003
  2. Jeremy Chapman
    Replies:
    1
    Views:
    935
    szabelin
    Aug 15, 2003
  3. Lundy
    Replies:
    0
    Views:
    687
    Lundy
    Oct 6, 2004
  4. =?Utf-8?B?ZGhucml2ZXJzaWRl?=

    force horizontal scrollbar display on div

    =?Utf-8?B?ZGhucml2ZXJzaWRl?=, Sep 2, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    5,211
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tp?=
    Sep 2, 2005
  5. Replies:
    2
    Views:
    180
    David Mark
    Jul 21, 2007
Loading...

Share This Page