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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:05:58+00:00 2026-05-12T10:05:58+00:00

I’ve got an Integer called x; if it changes then i would like to

  • 0

I’ve got an Integer called x; if it changes then i would like to update my table in a GUI. To listen to “x” I have tried

ChangeEvent y = new javax.swing.event.ChangeEvent(x);

and I implement javax.naming.event.ObjectChangeListener:

class HDIManagementView extends FrameView 
         implements ObjectChangeListener, ActionListener, TableModelListener  {

and I override the objectChanged method to update my table. Nothing happened

public void objectChanged(javax.naming.event.NamingEvent name){
//gets which status
    Object y=name.getChangeInfo();
    String m=y.toString();
    tableModel.setValueAt(y, 0, 0);

}`

if i change “x” then nothing changes in my table. What have I done wrong?

Second question is, x can only be called by value. i can only reach x from my database or my properties file. When database changes, x can’t understand if it changes or not Even if listener listens. All i do is listen y which equals x. When x changes y doesn’t understand because x is not calling by referens. What can i do?

  • 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-12T10:05:58+00:00Added an answer on May 12, 2026 at 10:05 am

    The answer to the question is “no – you can’t” and “JNDI and javax.naming is nothing to do with your problem”

    I think you may be confusing the Swing/JavaBeans listener framework with JNDI, the Java naming and Directory interface. An ObjectChangeListener is only useful for listening to objects which are bound and re-bound in a JNDI context. You cannot use an ObjectChangeListener to listen for changes on an arbitrary object

    InitialContext ctx = new InitialContext();
    ctx.rebind("path/to/x", new Integer(4));
    

    In order to do this, you need a JNDI implementation. In order to listen to the change, you listen on an EventContext:

    InitialContext ctx = new InitialContext();
    EventContext ec = (EventContext) ctx.lookup("");
    ec.addNamingListener("path/to/x", myListener)
    

    If you try this it will fail because you have not defined a JNDI provider. Typically these would be provided by an application-server vendor, e.g. IBM WebSphere or JBoss. The application server provides JNDI for applications to lookup resources like data sources, or configuration information.

    In order for you to do what you actually want, you’ll want to implement some class which wraps your integer and uses the property-change mechanism in Java:

    public class MyInteger {
      private int x;
      private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
      public void setX(int i) {
         int old = x;
         x = i;
         pcs.firePropertyChange("x", old, x); 
      }
    
      public void addListener(PropertyChangeListener l) {
          pcs.addListener("x", l);
      }
    }
    

    Then, this can be used by your code:

    MyInteger i = new MyInteger(9);
    i.addListener(new PropertyChangeListener() {
      public void propertyChanged(PropertyChangedEvent e) {
          //implement to process the change - e.g. update your table
          Integer i = (Integer) e.getNewValue();
      }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 218k
  • Answers 218k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer According to the Flex PMD website, the plugin seems to… May 12, 2026 at 11:34 pm
  • Editorial Team
    Editorial Team added an answer They are type4 UUIDs. Basically just a random string that… May 12, 2026 at 11:34 pm
  • Editorial Team
    Editorial Team added an answer You could start a separate eventloop, using QEventLoop, before calling… May 12, 2026 at 11:34 pm

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a French site that I want to parse, but am running into
I have text I am displaying in SIlverlight that is coming from a CMS
I want use html5's new tag to play a wav file (currently only supported

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.