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 931933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:34:57+00:00 2026-05-15T20:34:57+00:00

OK so I switched from JList to List because 1.) It doesn’t overlap my

  • 0

OK so I switched from JList to List because

1.) It doesn’t overlap my drawn images
2.) It can have focus disabled yet track what’s selected

Anyway, here’s the error I get when I try to compile:

C:\Users\Dan\Documents\DanJavaGen\inventory.java:30: cannot find symbol
symbol  : constructor List(java.lang.Object[])
location: class java.awt.List
        list = new List(arr.toArray());
               ^
C:\Users\Dan\Documents\DanJavaGen\inventory.java:50: cannot find symbol
symbol  : method getSelectedValue()
location: class java.awt.List
        Object index = list.getSelectedValue();
                           ^

The code:

import java.applet.Applet;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.ArrayList;
import java.io.*;
import java.util.*;
import java.awt.List;

public class inventory extends JApplet implements MouseListener {

public static String newline;
public static List list;
int gold = 123;

    public void init() {



ArrayList<String> arr = new ArrayList<String>();
arr.add("Hatchet");
arr.add("Sword");
arr.add("Shield");
arr.add(gold + " Gold");
System.out.println("You have " + arr.size() + " items in your inventory.");
showInventory(arr);



        list = new List(arr.toArray());

        add(list);

        list.addMouseListener(this);

        list.setVisible(true);

    }

public static void showInventory (ArrayList<String> theList) {
for (int i = 0; i < theList.size(); i++) {
System.out.println(theList.get(i));
}
}


    public void mousePressed(MouseEvent e) { }

    public void mouseReleased(MouseEvent e) {
        Object index = list.getSelectedValue();
       System.out.println("You have selected: " + index);
    }

    public void mouseEntered(MouseEvent e) { }

    public void mouseExited(MouseEvent e) { }

    public void mouseClicked(MouseEvent e) { }




    public void paint(Graphics g) {

    }
}
  • 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-15T20:34:58+00:00Added an answer on May 15, 2026 at 8:34 pm

    There are two issues at play here:

    java.awt.List does not have a constructor that takes Object[]:

    list = new List();
    for (String item : arr) {
        list.add(item);
    }
    

    java.awt.List has getSelectedItem() not getSelectedValue():

    You could your ArrayList with List as follows:

    public void mouseReleased(MouseEvent e) {
        Object index = list.getSelectedItem();
        System.out.println("You have selected: " + index);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have switched from sqlite to FireBird embedded server, because FB seems to support
I've just switched from radrails to netbeans. So far, so good. But I have
I have just switched from svn to mercurial and have read some tutorials about
I just switched from storing my images uploaded via Carrierwave locally to using Amazon
As you may have known that I switched from ubuntu to windows from my
I switched from xml to programmatically cache creation and now I can't retrieve my
EDIT: Switched from XmlTextWriter to XElement I have a Player class, which has following
I just switched from Visual Studio 2010 to Eclipse (Ubuntu). I have a global
I have just switched from Java Server Faces JSF 1.x to JSF 2.x. Files
I recently switched from VB to C# and have, for the most part, been

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.