Results 1 to 3 of 3
  1. #1
    lupo is offline Member
    Join Date
    Mar 2010
    Posts
    2
    Rep Power
    0

    Default ScrollBar in a JList

    Hello, I've a JList, and this JList must go in a JPanel.

    so:

    JList a = new JList();

    JPanel b = new JPanel();


    b.add(a);



    I want to pick a scrollBar in the JList, but, if I use the JScrollPane, then I can't add the JScrollPane in the JPanel.


    Any idea?


    Thankss.

  2. #2
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    5

    Default

    Quote Originally Posted by lupo View Post
    I want to pick a scrollBar in the JList, but, if I use the JScrollPane, then I can't add the JScrollPane in the JPanel.
    why not?

    Let's see your attempt.

  3. #3
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

    Default

    Quote Originally Posted by lupo View Post
    Any idea?
    create your JList and the put it into the JScrollPane, example

    Java Code:
    JScrollPane pane = new JScrollPane(myJList, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
    							ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    and the put the JScrollPane into the contentPane of your container.

Similar Threads

  1. JList with ScrollBar
    By Psyclone in forum AWT / Swing
    Replies: 5
    Last Post: 02-12-2010, 05:02 AM
  2. scrollbar issue
    By kumar_gemi in forum New To Java
    Replies: 9
    Last Post: 05-06-2009, 07:57 AM
  3. scrollbar issue
    By kumar_gemi in forum NetBeans
    Replies: 1
    Last Post: 05-03-2009, 11:23 PM
  4. how to add scrollbar in netbeans
    By kumar_gemi in forum NetBeans
    Replies: 1
    Last Post: 03-12-2009, 07:50 PM
  5. Using java.awt.Scrollbar
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-03-2008, 10:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •