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

  • Home
  • SEARCH
  • 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 8234221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:24:17+00:00 2026-06-07T18:24:17+00:00

Haven’t been able to find a definite answer. I know that one button can

  • 0

Haven’t been able to find a definite answer. I know that one button can have multiple listeners, but what about the inverse? Currently having an issue where the second button I have setup on a ButtonListener isn’t responding, and I’m wondering if that’s why. If what I was trying to do isn’t possible, how do you setup another ButtonListener?

As always, any assistance is appreciated.

Relevant Source:

import javax.swing.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.*;
import javax.imageio.*;
import java.text.NumberFormat;

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

    //Declarations so they have scope outside of ClientApp()
    private JButton switchCard;
    private JPanel infoPanel;
    private JPanel mainPanel;
    private JPanel cartPanel;
    private JPanel orderingPanel;
    private JList candyList;
    private CardLayout cl = new CardLayout();
    private CardLayout cl2 = new CardLayout();
    private JPanel checkoutPanel;
    private JButton checkoutButton;
    private JTextField acidPopsTF;
    private JTextField bertieBottsTF;
    private JTextField bloodPopsTF;
    private JTextField cauldronCakesTF;
    private JTextField charmChocTF;
    private JTextField chocoballsTF;
    private JTextField chocCauldronsTF;
    private JTextField chocFrogsTF;
    private JTextField chocWandsTF;
    private JTextField roachClustersTF;
    private JTextField crystalPineappleTF;
    private JTextField droobleGumTF;
    private JTextField explodeBonbonsTF;
    private JTextField fizzWhizTF;
    private JTextField iceMiceTF;
    private JTextField jellySlugsTF;
    private JTextField liquorWandsTF;
    private JTextField pepImpsTF;
    private JTextField pinkCocoIceTF;
    private JTextField spindleSpidersTF;
    private JTextField sugarQuillsTF;
    private JTextField wizochocTF;
    private JTextField shockChocTF;
    private ArrayList cart;
    private Object[] cartArray;

    public ClientApp()
    {
        this.setSize(750,400);
        this.setTitle("Honeydukes Muggle Ordering System");
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        ButtonListener bl = new ButtonListener();

        //Creating the panels
        mainPanel = new JPanel(cl2);
        cartPanel = new JPanel();
        orderingPanel = new JPanel(new BorderLayout());
        infoPanel = new JPanel(cl);
        JPanel invntryPanel = new JPanel(new BorderLayout());
        checkoutPanel = new JPanel(new BorderLayout());

//—–Code Code Code—-//

    //Creating the interface element for advancing to the checkout screen
    checkoutButton = new JButton("Checkout");
    checkoutButton.addActionListener(bl);
    checkoutPanel.add(checkoutButton, BorderLayout.LINE_END);

    //Adding everything to the frame
    orderingPanel.add(checkoutPanel, BorderLayout.PAGE_END);
    orderingPanel.add(invntryPanel, BorderLayout.LINE_START);
    orderingPanel.add(infoPanel, BorderLayout.CENTER);

    mainPanel.add(orderingPanel, "Ordering");
    mainPanel.add(cartPanel, "Cart");
    if (currentPage == 1)
    {
        cl2.show(mainPanel, "Cart");
    }

    if (currentPage == 0)
    {
        cl2.show(mainPanel, "Ordering");
    }

    this.add(mainPanel);
    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-07T18:24:19+00:00Added an answer on June 7, 2026 at 6:24 pm

    Definitely you may use use single listener for one or more Buttons. For more inforation read tutorial pages : Writing Event Listeners

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

Sidebar

Related Questions

I haven't been able to find what these Xcode icons mean. Some you can
Haven't been able to find this one out. How are Bitmaps stored in memory
I haven't been able to find any documentation on Android's sync services, so far
I haven't been able to find any real documentation on this, so I'm wondering
Haven't seen anything, but I have seen that you can create albums in the
I haven't been able to find authorative explanations, microformats or guidelines for the following,
I haven't been able to get any more console output (to help with debugging)
I have a jquery bug and I've been looking for hours now, I can't
I haven't seen this question anywhere else, I hope someone can help. I have
I haven't worked with SQL Reporting much, however I have been trying to get

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.