DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  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);
    >
    >




Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links