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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:49:49+00:00 2026-06-18T15:49:49+00:00

how are you?, i have a problem that i am sure is something really

  • 0

how are you?, i have a problem that i am sure is something really stupid but i can´t figure what it is. I am trying to create a button, so every time i want to use that button that does the action that i want, all i do is create that new button that already owns the action and the resourceBundle.

my code is this:

public class AcceptNewTaskButton extends JButton {

 private ActionManager actionManager;
 private JButton acceptNewTaskButton;

public AcceptNewTaskButton(JDialog dialog,JDateChooser dateChooser,JTextField      textField){

    super(ResourceBundle.getBundle("Language").getString("locale_button_accept"));
    actionManager = new ActionManager(dialog,dateChooser,textField);

    acceptNewTaskButton = new   JButton(actionManager.getNewTaskAction(dialog,dateChooser,textField));


}}

This code doesn’t do what i want, because when i code this

okbutton = new AcceptNewTaskButton(dialog,datechooser,newTaskName);

the button is created but it doesn´t perform any action.

But, on the other hand, when i code this

public class AcceptNewTaskButton extends JButton {

private ActionManager actionManager;
private JButton acceptNewTaskButton;

public JButton AcceptNewTaskButton(JDialog dialog,JDateChooser dateChooser,JTextField textField){


    actionManager = new ActionManager(dialog,dateChooser,textField);
    acceptNewTaskButton = new JButton(actionManager.getNewTaskAction());
    acceptNewTaskButton.setText(ResourceBundle.getBundle("Language").getString("locale_button_accept"));

    return acceptNewTaskButton;

}}

And i type this

okButton = new AcceptNewTaskButton().AcceptNewTaskButton(dialog,dateChooser,newTaskName);  

The action is perfectly performed.

I would like to know why this is happening, i think it is something simple but i can´t see it. I would like to do it this way because i want to have a class of every button in a package called buttons, and in this way make my code more “object oriented”

Thank you so much!

pd: excuse me if i commited any grammar mistake, english isn´t my native language

  • 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-18T15:49:51+00:00Added an answer on June 18, 2026 at 3:49 pm

    Your class already extends JButton so you don’t want to create a new button.

    I think you should be doing:

    // acceptNewTaskButton = new   JButton(actionManager.getNewTaskAction(dialog,dateChooser,textField));
    setAction(  actionManager.getNewTaskAction(dialog,dateChooser,textField) );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem that seems so senseless that I'm sure I'm missing something
I've just installed VS2008 and have run into a problem that I'm sure can
I have this problem that I can ref a button for control it. I
I have a weird problem that I can't solve. I'm trying to open a
I have this annoying problem, that Im pretty sure happens to all of you
I have a SimpleProducerConsumer class that illustrates a consumer/producer problem (I am not sure
I have a problem that I'm working on for quite some time now. I
I'm sure this is something really simple, like a misplaced quote, but I'm completely
I'm not really sure how I can explain this, but here goes: I want
First, yes it's HW - really tried but not sure of something so ill

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.