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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:51:55+00:00 2026-06-07T09:51:55+00:00

I’ve been encountering some issues with a Java program which I’ve begun developing. It

  • 0

I’ve been encountering some issues with a Java program which I’ve begun developing. It would be an online ordering system for the Honeydukes Candy Store of Harry Potter fame, and would be two separate programs. The client program would be in Swing, and would take the order and all that, sending it off to the server program when the order is made. The server program will be significantly less pretty, and its goal would be to write the orders to a text file before giving the green light to the client program that all went well.

For the client program, I’m wanting to have three panels, with the main panel containing the other two. On the left side would be the invntryPanel, containing a JList that has the store’s stock. The right side would hold the infoPanel, which uses the CardLayout to change between various panels, using the currently selected item from the JList to determine which panel to display. The infoPanel will also be where the user selects the quantity the wish to purchase.

A button whose position I haven’t quite decided on yet can be clicked when the user is done making their order, and it will bring up a separate window asking for general information(name, etc), as well as displaying their total. One final click of a button on that window will send the order to the server program, and the client application will close upon receiving confirmation from the server program that the request went through.

I’ve gotten started on it, but the compiler seems to be in a bad mood today. What am I doing wrong?

I do apologize for the fact that this is a self-centered question, but I’m just not really sure where else to turn to. I’ve checked multiple other resources and my code seems to be in order, but obviously it’s not.

Thank you in advance.

Source:

import javax.swing.*;
import java.util.*;
import java.awt.*;

public class ClientApp extends JFrame
{
    public static void main(String[] args)
    {
        new ClientApp();
    }


    public ClientApp()
    {
        this.setSize(320,200);
        this.setTitle("Honeydukes Candy Order");
        this.setDefaultCloseOperation(
            JFrame.EXIT_ON_CLOSE);

        ButtonListener bl = new ButtonListener();

        JPanel mainPanel = new JPanel();
        JPanel infoPanel = new JPanel(new CardLayout());
        JPanel invntryPanel = new JPanel();

        String[] candy = {"Acid Pops", "Bat's Blood Soup",
                          "Bertie Bott's Every Flavour Beans",
                          "Blood-flavoured Lollipops",
                          "Cauldron Cakes", "Charm Choc",
                          "Chocoballs", "Chocolate Cauldrons",
                          "Chocolate Frogs", "Chocolate Skeletons",
                          "Chocolate Wands", "Choco-Loco", "Cockroach Clusters",
                          "Nougat", "Crystallised Pineapple",
                          "Drooble's Best Blowing Gum", "Exploding Bonbons",
                          "Toffees", "Fizzing Whizzbees",
                          "Fudge Flies", "Ice Mice",
                          "Jelly Slugs", "Liquourice Wands",
                          "Pepper Imps", "Peppermint Toads",
                          "Pink Coconut Ice", "Pixie Puffs",
                          "Pumpkin Fizz", "Salt Water Taffy",
                          "Shock-o-Choc", "Skeletal Sweets",
                          "Splindle's Lick'O'Rish Spiders",
                          "Sugar Quills", "Sugared Butterfly Wings",
                          "Toothflossing Stringmints", "Tooth-Splintering Strongmints",
                          "Treacle Fudge", "Chocolates", "Wizochoc"};
        JList candyList = new JList(candy);
        candyList.setVisibleRowCount(candy.length);
        candyList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        JScrollPane scroll = new JScrollPane(candyList);
        invntryPanel.add(scroll);
        mainPanel.add(invntryPanel);
        this.setVisible(true);
    }
}

Errors:

ClientApp.java:20: error: cannot find symbol
                BasicButtonListener bl = new BasicButtonListener();
                ^
  symbol:   class BasicButtonListener
  location: class ClientApp
ClientApp.java:20: error: cannot find symbol
                BasicButtonListener bl = new BasicButtonListener();
                                             ^
  symbol:   class BasicButtonListener
  location: class ClientApp
Note: ClientApp.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors
  • 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-06-07T09:51:59+00:00Added an answer on June 7, 2026 at 9:51 am

    How about this to start with:

    String[] candy = new String[38];
    String[] candy = {"Acid Pops", "Bat's Blood Soup", /* ... */ };
    

    You’re trying to declare the same variable twice in the same scope. You can’t do that. Just get rid of the first declaration – the second one is fine.

    (Hint: get rid of the hard-coding of the number 38 twice. Use candy.length if you want to know how many elements the array has…)

    EDIT: Now we’ve seen the compiler errors, you also need to:

    • Fix up the arrays elements as per thegrinner’s answer
    • Work out what you mean by ButtonListener. Did you mean to use BasicButtonListener instead, perhaps?
    • Declare the candyList variable (currently you’re just trying to assign to it)
    • Add an import for java.awt.CardLayout

    The errors you’ve given are reasonably clear – except the multiple issues with candyList, which are all explained by the fact that you’re missing the declaration.

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

Sidebar

Related Questions

I would like to run a str_replace or preg_replace which looks for certain words
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.