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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:14:47+00:00 2026-05-29T20:14:47+00:00

The problem is as in question . I read the example so many times

  • 0

The problem is as in question.

I read the example so many times already, but I still can’t bring it to work.

The idea is to write an Event in Java and write a callback for MATLAB.

First I wrote my event class: package.EventTest.
Then I built it and in added the path with this classes to javaclasspath.

Then in matlab I execute:

evt = package.EventTest
set(evt,'TestEventCallback',@(h,e)disp(h))
evt.notifyMyTest

after line “evt.notifyMyTest” it should display something, but comes nothing.
I used a debugger and as it comes to function “notifyMyTest” I see that the vector with listeners is empty. So it can’t show anything. What do I do wrong?
Does this line “set(evt,’TestEventCallback’,@(h,e)disp(h))” have to add listener to this vector?

Or maybe there is another one possibility to challenge it?

Thanks in advance,
Lex

UPD: My Java class in package “package” (example):

public class EventTest {

    private java.util.Vector data = new java.util.Vector();
    public synchronized void addMyTestListener(MyTestListener lis) {
        data.addElement(lis);
    }
    public synchronized void removeMyTestListener(MyTestListener lis) {
        data.removeElement(lis);
    }
    public interface MyTestListener extends java.util.EventListener {
        void testEvent(MyTestEvent event);
    }
    public class MyTestEvent extends java.util.EventObject {
        private static final long serialVersionUID = 1L;
        public float oldValue,newValue;        
        MyTestEvent(Object obj, float oldValue, float newValue) {
            super(obj);
            this.oldValue = oldValue;
            this.newValue = newValue;
        }
    }
    public void notifyMyTest() {
        java.util.Vector dataCopy;
        synchronized(this) {
            dataCopy = (java.util.Vector)data.clone();
        }
        for (int i=0; i<dataCopy.size(); i++) {
            MyTestEvent event = new MyTestEvent(this, 0, 1);
        ((MyTestListener)dataCopy.elementAt(i)).testEvent(event);
        }
    }
}
  • 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-29T20:14:49+00:00Added an answer on May 29, 2026 at 8:14 pm

    I think, I found another way to do what I want.
    Now I use PropertyChangeSupport and PropertzChangeListener.

    In Matlab I add

    ‘PropertyChangeCallback’

    Then from Java-code I send

    firePropertyChange(“Property”, oldValue, newValue)

    And my Matlab code is notified.

    Looks like it’s working

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

Sidebar

Related Questions

Yes, I have already asked this question, but the problem is much more specific.
I've read the related questions but I cannot find one that suits my problem(or
Problem This question actually came up at work today. We are planning an experiment
simple problem with a simple question. I have a string, in C# i can
I seem to have faced this problem many times and I wanted to ask
Referring on this question , I have a similar -but not the same- problem..
I'm encountering a common TableView data reloading problem. I've read many questions on the
Forgive me for yet another question on Python decorators. I did read through many
I know this question was asked before (for example here and here ) but
Another noob regex problem/question. I'm probably doing something silly so I thought I'd exploit

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.