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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:23:39+00:00 2026-06-11T20:23:39+00:00

I am Swing novice. I made a small app using JTree, JCheckBox, JList and

  • 0

I am Swing novice. I made a small app using JTree, JCheckBox, JList and JButton. I am using the associated model classes to store the presentation state. Works fine, except for the JButton. I’d like to update the button’s text according to a property of my model. Basically, it will change from log in/to log off whether the user is currently logged in. Unfortunatly, I can’t find a setText method in the ButtonModel interface. Can anybody tell me how to do this ?

Thanks. PW.

  • 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-11T20:23:40+00:00Added an answer on June 11, 2026 at 8:23 pm

    For a JButton you can use an Action as your model. The Action interface defines keys which are used by the JButton to retrieve its state from the Action, including one for the text: Action.NAME

    If you look at the source code, the constructor with the Action (or simply the setAction method) uses more information from the Action then what can be retrieved from a ButtonModel. Same for other constructors, e.g.

    public JButton(String text, Icon icon) {
        // Create the model
        setModel(new DefaultButtonModel());
    
        // initialize
        init(text, icon);
    }
    

    So it seems that you are correct in your assessment that the ButtonModel does not contain all information used to visualize a typical JButton

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

Sidebar

Related Questions

In Swing when using a JTree/JList/JTable selecting an item changes its background color. Is
I have a Swing app, that I start using JNLP. When I start using
in the a swing app i'm rendering text with a custom JComponent , using
Using Swing in Java I wrote a form containing radio buttons, text fields and
My swing app has a main window which has sever buttons. This JFrame is
I had a gui (swing) project developed using netbeans 7 and JDK 6. Then
My Swing Application's GUI is built using Window Builder Pro GUI editor. Layouts used
I am using Google Web Toolkit's Swing Designer in Eclipse to create and edit
I have a Swing app with a large panel which is wrapped in a
In my Swing app. I have a JFrame with few JPanels . One of

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.