File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Horizontal Scroll Bar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Horizontal Scroll Bar" Watch "Horizontal Scroll Bar" New topic
Author

Horizontal Scroll Bar

Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
I have a JScrollPane that I can't seem to slap a horizontal scroll bar onto.
Here's my code for my JScrollPane...

This scroll pane is sitting in a JPanel that has a layout of BorderLayout. Does that make a difference? When the table is populated with data, is sizes all of the columns so they fit within the panel. When the user expands one of the columns, I want them to be able to scroll horizontally. What am I doing wrong?
Thanks for any help!
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2833
    
  11

Try this on your table:
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
That worked, however, now my columns are all scrunched together. How can I still have my scrollbar appear, but have the columns as wide as the column headings. Or, how can I specify what the column width is supposed to be for a particular column?
Thanks again!
Younes Essouabni
Ranch Hand

Joined: Jan 13, 2002
Posts: 479
I don't know for the scrollbar, but for the column's wide, you can proceed like this. I don't know if it is the best way.

I hope it's helping you


Younes
By constantly trying one ends up succeeding. Thus: the more one fails the more one has a chance to succeed.
Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
Younes,
That worked! Now I have my horizontal scroll bar, and my columns aren't scrunched together!
Thanks for all of your help!
Have a GREAT day!!!
Younes Essouabni
Ranch Hand

Joined: Jan 13, 2002
Posts: 479
Thx for the reply.
Nice to see it works
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Horizontal Scroll Bar
 
Similar Threads
How to gray out one particular row in JTable
nx:All of URLy Bird 1.1.3 about JTable
JTable and Horizontal Scroll Bar
jscroll pane problem.
need help to set horizontal bar to JList