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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:48:40+00:00 2026-06-16T00:48:40+00:00

JButton won’t show SHORT_DESCRIPTION, nor does the setEnabled work. … ButtonAction action = new

  • 0

JButton won’t show SHORT_DESCRIPTION, nor does the setEnabled work.

...
ButtonAction action = new ButtonAction();
command.addActionListener(action);

class ButtonAction extends AbstractAction{

    public ButtonAction(){
        putValue(Action.SHORT_DESCRIPTION, "Comnine the two value");
        setEnabled(false);
    }
    public void actionPerformed(ActionEvent event){

    }
}
  • 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-16T00:48:41+00:00Added an answer on June 16, 2026 at 12:48 am

    You have to create the button with the Action or use setAction(); addActionListener() by itself is not sufficient. Here’s a complete example; see How to Use Actions for examples and Action for more on bound properties.

    import java.awt.EventQueue;
    import java.awt.event.ActionEvent;
    import javax.swing.AbstractAction;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    
    /** @see http://stackoverflow.com/a/13944679/230513 */
    public class ActionTest {
    
        private void display() {
            JFrame f = new JFrame("ActionTest");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.add(new JButton(new ButtonAction()));
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
        }
    
        class ButtonAction extends AbstractAction {
    
            public ButtonAction() {
                putValue(NAME, "Button");
                putValue(SHORT_DESCRIPTION, "Combine the two values");
                setEnabled(false);
            }
    
            @Override
            public void actionPerformed(ActionEvent event) {
                System.out.println(event);
            }
        }
    
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable() {
    
                @Override
                public void run() {
                    new ActionTest().display();
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have JButton test = new JButton(Test Button); and I want to
Possible Duplicate: JTable won’t show column headers How to see column labels in JTable?
I have some code for a JButton: solutionButton = new JButton(Solution); solutionButton.setBorderPainted( false); solutionButton.setContentAreaFilled(
I have a 2D-Array of JButtons JButton[][] ledBtns = new JButton[8][8]; And in a
I have created a JButton class that recieving Action, the JButton class includes keystrokes
I have a JButton and when a player clicks it it tell my Action
I am trying to rotate a graphic, but for some reason it won't work.
I have a JButton that is constructed using an Action and this action has
I have a JButton, in a JPanel, in a JApplet, that when clicked, does
JButton btnNewButton = new JButton(Register Student); btnNewButton.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0)

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.