Trouble gettings JList to scroll

Swing Designer allows you to quickly create the frames, panels, dialogs, applets and other UI elements that comprise Java Swing applications.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

Trouble gettings JList to scroll

Postby James Bolver » Mon May 02, 2005 2:27 pm

Hi,

I'm new to Swing and like the subject says am haivng problems getting my Jlist to scroll. I know that JList does not scroll natively (why does the JList icon have a scroll bar on it then) and that I need to make an instance of a JScrollPane, or do i ?

I tried the scroll bar component w/ no luck.

This is my code:
Code: Select all
...
myList = new JList();
myList.setBounds(13, 24, 250, 280);
panel_1.add(myList);
panel_1.add(new JScrollPane(myList));
listPid.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
...


This doesnt show any object in the position that the JList should be in,

I know i am missing somthing obvious here, but does anyone have any advice ?

Thanks,
James
James Bolver
 

Re: Trouble gettings JList to scroll

Postby Eric Clayberg » Mon May 02, 2005 5:52 pm

James Bolver wrote:I know i am missing somthing obvious here, but does anyone have any advice ?

You need to first add a JScrollPane to you panel and then add the JList to scrollpane as its viewport.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to Swing Designer

Who is online

Users browsing this forum: No registered users and 1 guest