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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:14:24+00:00 2026-05-17T06:14:24+00:00

I’m stuck again trying to figure out how to out the button clicked to

  • 0

I’m stuck again trying to figure out how to out the button clicked to label1.

When I click button01 I get A printed out. I need it to print to the label1 though and say Folder A when A is pressed and B when B is pressed and so on. Any nudge in the right direction?

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class JFileCabinet extends JFrame {

    private JButton button01 = new JButton("A");
    private JButton button02 = new JButton("B");
    private JButton button03 = new JButton("C");
    private JButton button04 = new JButton("D");
    private JButton button05 = new JButton("E");
    private JButton button06 = new JButton("F");
    private JButton button07 = new JButton("G");
    private JButton button08 = new JButton("H");
    private JButton button09 = new JButton("I");
    private JButton button10 = new JButton("J");
    private JButton button11 = new JButton("K");
    private JButton button12 = new JButton("L");
    private JButton button13 = new JButton("M");
    private JButton button14 = new JButton("N");
    private JButton button15 = new JButton("O");
    private JButton button16 = new JButton("P");
    private JButton button17 = new JButton("Q");
    private JButton button18 = new JButton("R");
    private JButton button19 = new JButton("S");
    private JButton button20 = new JButton("T");
    private JButton button21 = new JButton("U");
    private JButton button22 = new JButton("V");
    private JButton button23 = new JButton("W");
    private JButton button24 = new JButton("X");
    private JButton button25 = new JButton("Y");
    private JButton button26 = new JButton("Z");
    private JButton button27 = new JButton(" ");
    private JButton button28 = new JButton(" ");
    private JButton button29 = new JButton(" ");
    private JButton button30 = new JButton(" ");
    private static JLabel label1 = new JLabel("Folder ");
    private JPanel panel01 = new JPanel(new GridLayout(1, 6));
    private JPanel panel02 = new JPanel(new GridLayout(1, 6));
    private JPanel panel03 = new JPanel(new GridLayout(1, 6));
    private JPanel panel04 = new JPanel(new GridLayout(1, 6));
    private JPanel panel05 = new JPanel(new GridLayout(1, 2));
    private GridLayout layout = new GridLayout(5, 1, 5, 5);

    public JFileCabinet() {

        setLayout(layout);
        add(panel01);
        add(panel02);
        add(panel03);
        add(panel04);
        add(panel05);

        button01.addActionListener(new ButtonListener());
        panel01.add(button01);

        panel01.add(button02);
        panel01.add(button03);
        panel01.add(button04);
        panel01.add(button05);
        panel01.add(button06);

        panel02.add(button07);
        panel02.add(button08);
        panel02.add(button09);
        panel02.add(button10);
        panel02.add(button11);
        panel02.add(button12);

        panel03.add(button13);
        panel03.add(button14);
        panel03.add(button15);
        panel03.add(button16);
        panel03.add(button17);
        panel03.add(button18);

        panel04.add(button19);
        panel04.add(button20);
        panel04.add(button21);
        panel04.add(button22);
        panel04.add(button23);
        panel04.add(button24);

        panel05.add(button25);
        panel05.add(button26);
        panel05.add(button27).setVisible(false);
        panel05.add(button28).setVisible(false);
        //panel05.add(button29).setVisible(false);
        panel05.add(label1);
        panel05.add(button30).setVisible(false);

        setSize(400, 350);
        setVisible(true);
    }
    public static void main(String[] args) {
        JFileCabinet frame = new JFileCabinet();
    }
    String selection;
    class ButtonListener implements ActionListener {
        private String e;
        public void actionPerformed(ActionEvent e) {
            //throw new UnsupportedOperationException("Not supported yet.");
            String clicked = null;
            if (e.getActionCommand().equals("A")) {                //clicked.equals("A");
                System.out.println("A");
            }
        }
    }
}
  • 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-17T06:14:24+00:00Added an answer on May 17, 2026 at 6:14 am
    label1.setText("Folder " + e.getActionCommand());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I'm trying to select an H1 element which is the second-child in its group
I need a function that will clean a strings' special characters. I do NOT
I'm parsing an XML file, the creators of it stuck in a bunch social
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

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.