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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:25:16+00:00 2026-06-07T17:25:16+00:00

I’m currently working on a program which I’ve asked questions involving previously . I’ve

  • 0

I’m currently working on a program which I’ve asked questions involving previously.

I’ve made a good amount of progress since then, and now I’m ready to begin on the infoPanel portion of the client program. I’ve read through the documentation and other questions, but I’m a still a bit confused. How do I setup the panel to, y’know, work? How do I link it with the JList(If that’s even possible to use a JList instead of a combo box), and then how do I establish which selection references which card?

Thank you so much for any assistance!

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,380);
        this.setTitle("Honeydukes Candy Order");
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setLayout(new BorderLayout());

        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(18);
        candyList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

        JScrollPane scroll = new JScrollPane(candyList, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                                             JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        invntryPanel.add(scroll);

        JPanel startCard = new JPanel();
        JPanel acidPopsCard = new JPanel();
        JPanel batsBloodSoupCard = new JPanel();
        JPanel bertieBottsCard = new JPanel();
        JPanel bloodPopsCard = new JPanel();
        JPanel cauldronCakesCard = new JPanel();
        JPanel charmChocCard = new JPanel();
        JPanel chocoballsCard = new JPanel();
        JPanel chocCauldronsCard = new JPanel();
        JPanel chocFrogsCard = new JPanel();
        JPanel chocSkeleCard = new JPanel();
        JPanel chocWands = new JPanel();
        JPanel chocolocoCard = new JPanel();
        JPanel roachClustersCard = new JPanel();
        JPanel nougatCard = new JPanel();
        JPanel crystalPineappleCard = new JPanel();
        JPanel droobleGumCard = new JPanel();
        JPanel explodeBonbonsCard = new JPanel();
        JPanel toffeesCard = new JPanel();
        JPanel fizzWhizCard = new JPanel();
        JPanel fudgeFliesCard = new JPanel();
        JPanel iceMiceCard = new JPanel();
        JPanel jellySlugsCard = new JPanel();
        JPanel liquorWandsCard = new JPanel();
        JPanel pepImpsCard = new JPanel();
        JPanel pinkCocoIceCard = new JPanel();
        JPanel pixiePuffsCard = new JPanel();
        JPanel pumpkFizzCard = new JPanel();
        JPanel saltTaffeyCard = new JPanel();
        JPanel shockChocCard = new JPanel();
        JPanel skeleSweetsCard = new JPanel();
        JPanel spindleSpidersCard = new JPanel();
        JPanel sugarQuillsCard = new JPanel();
        JPanel sugarWingsCard = new JPanel();
        JPanel flossMintsCard = new JPanel();
        JPanel splintMintsCard = new JPanel();
        JPanel treacleFudgeCard = new JPanel();
        JPanel chocolatesCard = new JPanel();
        JPanel wizochocCard = new JPanel();

        infoPanel.add(startCard);
        infoPanel.add(acidPopsCard);
        infoPanel.add(batsBloodSoupCard);
        infoPanel.add(bertieBottsCard);
        infoPanel.add(bloodPopsCard);
        infoPanel.add(cauldronCakesCard);
        infoPanel.add(charmChocCard);
        infoPanel.add(chocoballsCard);
        infoPanel.add(chocCauldronsCard);
        infoPanel.add(chocFrogsCard);
        infoPanel.add(chocSkeleCard);
        infoPanel.add(chocWands);
        infoPanel.add(chocolocoCard);
        infoPanel.add(roachClustersCard);
        infoPanel.add(nougatCard);
        infoPanel.add(crystalPineappleCard);
        infoPanel.add(droobleGumCard);
        infoPanel.add(explodeBonbonsCard);
        infoPanel.add(toffeesCard);
        infoPanel.add(fizzWhizCard);
        infoPanel.add(fudgeFliesCard);
        infoPanel.add(iceMiceCard);
        infoPanel.add(jellySlugsCard);
        infoPanel.add(liquorWandsCard);
        infoPanel.add(pepImpsCard);
        infoPanel.add(pinkCocoIceCard);
        infoPanel.add(pixiePuffsCard);
        infoPanel.add(pumpkFizzCard);
        infoPanel.add(saltTaffeyCard);
        infoPanel.add(shockChocCard);
        infoPanel.add(skeleSweetsCard);
        infoPanel.add(spindleSpidersCard);
        infoPanel.add(sugarQuillsCard);
        infoPanel.add(sugarWingsCard);
        infoPanel.add(flossMintsCard);
        infoPanel.add(splintMintsCard);
        infoPanel.add(treacleFudgeCard);
        infoPanel.add(chocolatesCard);
        infoPanel.add(wizochocCard);

        this.add(invntryPanel, BorderLayout.WEST);
        this.add(infoPanel, BorderLayout.EAST);
        this.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-06-07T17:25:19+00:00Added an answer on June 7, 2026 at 5:25 pm

    I would add a ListSelectionListener to the JList, and inside of that listener change the card displayed by the CardLayout.

    You really need to read the tutorial on how to use CardLayout first though as there you’d see that your add method is wrong. Consider using the Strings held by the JList as the constant that you’d use when adding components to the CardLayout-using panel.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
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 want use html5's new tag to play a wav file (currently only supported
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I am currently running into a problem where an element is coming back from
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

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.