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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:51:13+00:00 2026-05-14T07:51:13+00:00

So I am trying to get my GUI to work. When I run the

  • 0

So I am trying to get my GUI to work. When I run the code below, it does nothing, and I’m sure I’m probably just doing something dumb, but I am completely stuck…

public void actionPerformed(ActionEvent e){
    UI.getInstance().sS++;

    if((UI.getInstance().sS %2) != 0){
        UI.getInstance().startStop.setName("STOP");
        UI.getInstance().change.setEnabled(false);
    }else if(UI.getInstance().sS%2 == 0){
        UI.getInstance().startStop.setName("START");
        UI.getInstance().change.setEnabled(true);
    }


}

public void setStartListener(StartHandler e){
    this.startStop.addActionListener(e);
}

sS is an int that increments every time the button startStop is clicked. change is also a button.

  • 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-14T07:51:14+00:00Added an answer on May 14, 2026 at 7:51 am

    Here’s an example that shows a different approach to managing a Start/Stop button. It uses an instance of javax.swing.Timer to pace updates. Encapsulating the control button and display label may simplify maintenance. This variation illustrates adding a third command to pause updates.

    private static final String Start = "Start";
    private static final String Stop = "Stop";
    …
    private static void create() {
        …
        final JButton button = new JButton(Stop);
        button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                String cmd = e.getActionCommand();
                if (Stop.equals(cmd)) {
                    jtl.stop();
                    button.setText(Start);
                } else {
                    jtl.start();
                    button.setText(Stop);
                }
    
            }
        });
        …
    }
    

    More generally, use Action to encapsulate functionality for use elsewhere in your program. This example "exports several actions that make it easy to use them in a control panel."

    image

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

Sidebar

Related Questions

I just can't seem to get this to work at all. I'm trying to
I just can't seem to get this to work at all. I'm trying to
I'm trying get values from a GridView using the following code: foreach (GridViewRow row
Trying to get comfortable with jQuery and I have encountered some sample code that
Trying to get this to work, with no luck: [DataMember] public Type ParameterType {
Trying to get a JSON output to work with jqGrid 'userdata' option. The example
I've been trying to get this program to work, but when I try to
DISCLAIMER : this is the classic case of .NET GUI trying to work his
I'm trying to run a GUI unit test with DUnit to an application whose
I'm new to Java GUI and trying to work with jTable's in SWING. I

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.