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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:16:45+00:00 2026-05-15T21:16:45+00:00

First off, I am pretty new to java and I am just staring to

  • 0

First off, I am pretty new to java and I am just staring to get the hang of how static classes can interface with non-static classes and how to get a static class to update a textbox.

I keep searching for information, but I cannot find anything. I need a variable listener. here is something like what I am trying to do:

public class Class1{

public static int X;
public static void Process(){
   for (true){
        X = X + 1;
    }
}

Then I have another class where I want to bind a variable to a textbox

Public class Class2{
  ****** On Class1.X.changeValue { Form.jLabel1.setText(Class1.X) }
}

I hope I was clear on what I am trying to do. I am trying to bind a label to a variable.

  • 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-15T21:16:46+00:00Added an answer on May 15, 2026 at 9:16 pm

    In Java there is no language specific way to have listeners on variables. What you will need to do is when your code changes the variable then have it also update the JLabel.
    You can have listeners on buttons and other UI widgets and they might update the JLabel.
    One way you might implement this is as follows. Do you know about getters and setters ? They are methods that do the getting and setting of instance variables.

    private int x;
    
    public int getX()
    {
        return x;
    }
    
    public void setX(int anX)
    {
        x = anX;
        updateLabel("This is x:" + anX)
    }
    
    public void process()
    {
        while(true)
        {
            int anX = getX();
            setX(anX + 1);
        }
    }
    

    You should really try to minimize the use of statics as much as possible, They tend to encourage “Global Variables”

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

Sidebar

Related Questions

I've found several jQuery syntaxes for nullifying the enter on a form. First one:
I was reading JavaScript: The Good Parts and the author mentions that JavaScript is
I'm trying to build a C++ extension for python using swig. I've followed the
I am attempting to pull some information from my tnsnames file using regex. I
This is beyond both making sense and my control. That being said here is
Let say I have the following desire, to simplify the IConvertible's to allow me
After having read Ian Boyd 's constructor series questions ( 1 , 2 ,
I am using a 3rd-party rotator object, which is providing a smooth, random rotation

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.