Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Swing / AWT / SWT and the fly likes Scrolling in a JScrollPane problem 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 "Scrolling in a JScrollPane problem" Watch "Scrolling in a JScrollPane problem" New topic

Scrolling in a JScrollPane problem

Barry Brashear
Ranch Hand

Joined: Jun 05, 2001
Posts: 303
I have created a JList was built with a vector of
strings and then loaded into a JScrollPane. The scrollbars for the JScrollPane have both been set up as always. Some of the text in the JList is long and does not show in the list.
My problem is in the horizontal scrolling. The vertical scrollbar scrolls up and down, however, if the text is too long horizontally, I see several dots to the right but when I click the horizontal scrollbar nothing happens.
Any ideas??? I'm stuck.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299

Let's see the code.

GenRocket - Experts at Building Test Data
Barry Brashear
Ranch Hand

Joined: Jun 05, 2001
Posts: 303
// listOne is the JList and
// scrollOne is the JScrollPane
// listItems is a Vector of strings
listOne = new JList( listItems );
listOne.setCellRenderer(new TextListRenderer
listItems.elementAt( startIndex ), true);
listOne.setSelectionMode ( (ListSelectionModel.SINGLE_SELECTION);
listOne.setFont( new Font( "serif", Font.BOLD, 18 ) );

scrollOne = new JScrollPane( listOne, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS );
Bhagya Tangutur
Ranch Hand

Joined: Oct 21, 2002
Posts: 88
I guess your calling setFixedCellWidth(xx) method...which restricts the Label Width...try removing it.

Sun Certified Java Programmer
I agree. Here's the link:
subject: Scrolling in a JScrollPane problem
Similar Threads
JScrollPane without horizontal scrolling
Tricky JTextArea problem
Need ScrollPane with just VERTICAL Scrolling facility
need help to set horizontal bar to JList
relayouting after setViewportView for JScrollPane