JTable scrolling issue

Discussion in 'Java' started by Ray.Jaramillo@gmail.com, Mar 12, 2007.

  1. Guest

    I have a JTable in a JScrollPane but I do not want the first two
    colums to scroll when I move the scroll bar. I want the first two
    columns to stay on the screen and the rest of the columns in my JTable
    to scroll. Is there any way to make the first two columns permanent??
    I have looked around and can't seem to come up with any answer besides
    putting them in seperate JScrollPanes, but I want the scroll bar to
    span the entire Pane.

    Thank you ahead for any help,

    Ray
    , Mar 12, 2007
    #1
    1. Advertising

  2. Daniel Pitts Guest

    On Mar 12, 1:57 pm, ""
    <> wrote:
    > I have a JTable in a JScrollPane but I do not want the first two
    > colums to scroll when I move the scroll bar. I want the first two
    > columns to stay on the screen and the rest of the columns in my JTable
    > to scroll. Is there any way to make the first two columns permanent??
    > I have looked around and can't seem to come up with any answer besides
    > putting them in seperate JScrollPanes, but I want the scroll bar to
    > span the entire Pane.
    >
    > Thank you ahead for any help,
    >
    > Ray


    I'm not quite sure what your asking... Perhaps you want two tables,
    one that scrolls and one that doesn't?

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(permanentTable, BorderLayout.WEST);
    panel.add(new JScrollPane(scrollingTable), BorderLayout.CENTER);
    Daniel Pitts, Mar 13, 2007
    #2
    1. Advertising

  3. wrote:
    > I have a JTable in a JScrollPane but I do not want the first two
    > colums to scroll when I move the scroll bar. I want the first two
    > columns to stay on the screen and the rest of the columns in my JTable
    > to scroll. Is there any way to make the first two columns permanent??
    > I have looked around and can't seem to come up with any answer besides
    > putting them in seperate JScrollPanes, but I want the scroll bar to
    > span the entire Pane.
    >
    > Thank you ahead for any help,
    >
    > Ray
    >

    Somewhere in the JTable class, there is a protected method that prepares
    the table for a scroll pane (something along the lines of
    prepareTable()). If you fiddle with that and ColumnModels, you should be
    able to get what you want.
    Joshua Cranmer, Mar 13, 2007
    #3
    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. Tivo Escobar
    Replies:
    1
    Views:
    7,316
    manusa
    Apr 12, 2007
  2. apattin
    Replies:
    2
    Views:
    2,727
    alejandrina
    Apr 28, 2006
  3. Tintin92
    Replies:
    1
    Views:
    1,700
    Andrew Thompson
    Feb 14, 2007
  4. Mel
    Replies:
    3
    Views:
    94
    kaeli
    Mar 25, 2005
  5. Haircuts Are Important
    Replies:
    3
    Views:
    318
    Haircuts Are Important
    Jun 4, 2013
Loading...

Share This Page