Scrollable Jlist


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Scrollable Jlist

  1. #1
    matt Guest

    Scrollable Jlist


    Hi,

    I am having trouble displaying a scrollable JList. I wrapped it in a JScrollPane,
    but I can't get it to display. When I add the component to a JPanel, do
    I add the Jlist or the JScrollPane? Do I need a JScrollBar object? Please
    help. Thanks.

    Here is my code:

    private JPanel panelAreas = new JPanel(null);
    private JList areaRestrictedAreas = new JList();
    private JScrollPane restrictedScrollPane = new JScrollPane(areaRestrictedAreas);
    private JScrollBar restrictedScrollBar = new JScrollBar();

    restrictedScrollPane.setVerticalScrollBar(restrictedScrollBar);
    panelAreas.add(restrictedScrollPane);
    panelAreas.add(restrictedScrollBar);



  2. #2
    Paul Clapham Guest

    Re: Scrollable Jlist

    You add the JScrollPane. It will create its own JScrollBar objects as it
    needs them.

    And you are probably having trouble getting it to display because you didn't
    specify a layout manager.

    PC2

    "matt" <mrodgers@wam.umd.edu> wrote in message
    news:3c0c078a$1@147.208.176.211...
    >
    > Hi,
    >
    > I am having trouble displaying a scrollable JList. I wrapped it in a

    JScrollPane,
    > but I can't get it to display. When I add the component to a JPanel, do
    > I add the Jlist or the JScrollPane? Do I need a JScrollBar object?

    Please
    > help. Thanks.
    >
    > Here is my code:
    >
    > private JPanel panelAreas = new JPanel(null);
    > private JList areaRestrictedAreas = new JList();
    > private JScrollPane restrictedScrollPane = new

    JScrollPane(areaRestrictedAreas);
    > private JScrollBar restrictedScrollBar = new JScrollBar();
    >
    >

    restrictedScrollPane.setVerticalScrollBar(restrictedScrollBar);
    > panelAreas.add(restrictedScrollPane);
    > panelAreas.add(restrictedScrollBar);
    >
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center