Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6714945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:33:18+00:00 2026-05-26T08:33:18+00:00

I am trying to display a list of items using DefaultListModel and JList but

  • 0

I am trying to display a list of items using DefaultListModel and JList but my window is empty. What is the error?

see code:

    public class ViewInventoryInterface extends JFrame {
    private Inventory theInventory; // reference to back end
    private InventoryUPCIterator iter;
    private DefaultListModel dlm;
    private JList list;
    private JScrollPane scroll;

    public ViewInventoryInterface(Inventory theInventory) {
        this.theInventory = theInventory;
        iter = theInventory.inventoryUPCIterator(); //returns an iterator for the inventory
        dlm = new DefaultListModel();
        while (iter.hasNext()) {
            dlm.addElement(iter.next().toString());
        }
        list = new JList(dlm);
        scroll = new JScrollPane(list);
        setTitle("Inventory");
        setSize(400, 400);
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        setLocationRelativeTo(null);
        setVisible(true);    
    }
} 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:33:18+00:00Added an answer on May 26, 2026 at 8:33 am

    A first problem might be that you’re not adding anything to your frame. Use getContentPane().add(...) etc. to add your scroll pane to the frame.

    Depending on the layout manager you might need to have different additional parameters but with the default BorderLayout just adding should work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to display only selected items in list view. public class Mact
I'm trying to display a list coming from my database using Linqtosql but I
I am trying to display a list of items in a datagrid from an
I'm trying to display a list of check-ins in a venue using the following
I’m trying to display a list of shops each with 3 random items from
I'm trying to set up a page where I display a list of items
Im trying to display this listview, but I keep getting a: 07-17 21:14:22.233: ERROR/AndroidRuntime(349):
I am trying to dynamically add items to a list adapter using an alert
I have Custom List to display image with it's name like below... public class
I am trying to create a carousel, using floated list items. When Next is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.