Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling an object from another class (java, javafx)
    text
    copied!<p>I'm already working on this for weeks to get it working but without success. I'm using Javafx and java for implementing a small chat programm using the smack API (xmpp). The problem is how to get the received messages from java to javafx. The code below is actualy working when I have variable with a static string like "test message" and calling postMessage in java to send it to javafx. But how do I get another object (MessageListener) from java calling postMessage?</p> <pre><code>public class Java_callback implements RunnableFuture { FXListener listener; public String testmsg; public Java_callback(FXListener listener) { this.listener = listener; } @Override public void run() throws Exception { postMessage(testmsg); } public void postMessage(final String msg) { Entry.deferAction(new Runnable() { @Override public void run() { listener.callback(msg); } }); } } </code></pre> <p>Here the code for processing the message. This part somehow need to call postMessage from the code above.</p> <pre><code> public void xmpp_create_chat(String msg) { ChatManager chatmanager = connection.getChatManager(); Chat newChat = chatmanager.createChat("admin@unfc", new MessageListener() { @Override public void processMessage(Chat chat, Message message) { //msgArray.add( new String("Received message: " + message.getBody()) ); //msg_return = "blabla"; //java_callback.postMessage(msg_return); //test.postMessage(message.getBody()); //System.out.println("Received message: " + message); } }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload