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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:05:59+00:00 2026-06-16T00:05:59+00:00

I am creating a universal chat application using JavaFX. I created a listView using

  • 0

I am creating a universal chat application using JavaFX. I created a listView using SceneBuilder and modeled it with ObservableList like below:

public static ObservableList<String>  members = FXCollections.observableArrayList();

@FXML public static Button send;
@FXML static  ListView names;
@FXML static HTMLEditor outmsg;
@FXML static HTMLEditor showBox;

static void updateRemove(String newuser) {

 //   showBox.setHtmlText(showBox.getHtmlText()+newuser+"<br>  has left room");
    System.out.println(newuser+"has left room");
    members.remove(newuser);
    System.out.println("helloji update remove");


}
@FXML public void sendAction(ActionEvent event)
{


 LoginController.instance.c.sendMessage(outmsg.getHtmlText());


}
public  static void updateList(String name)
{
   // showBox.setHtmlText(showBox.getHtmlText()+"<br> new user entered in room");
    System.out.println("new user enterd"+name);
    System.out.println("beginning update list");
    members.add(name);
    System.out.println(members);
    System.out.println("add user request fullfilled");


}
 public  static void initList(Vector<String> name)
{
    System.out.println("list initializing");
    members.setAll(name);
      System.out.println(members);
    System.out.println("list initialized");

    System.out.println("public room created");


}
public static void showMessage(String msg)
{

   // showBox.setHtmlText(showBox.getHtmlText()+""+msg);
        System.out.println("showing msg   "+msg);
}

@Override
public void initialize(URL url, ResourceBundle rb) {
    // TODO



     names.setItems(members);
    // showBox.setHtmlText(showBox.getHtmlText()+"<br> welcome "+Client.username);
         System.out.println("welcome  "+Client.username);

     System.out.println(names.getItems());

}    

}

but when its updateRemove() method is called, exception is thrown:

java.lang.IllegalStateException: Not on FX application thread; currentThread = Thread-4
    at com.sun.javafx.tk.Toolkit.checkFxUserThread(Unknown Source)
    at com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(Unknown Source)
    at javafx.scene.Parent$1.onProposedChange(Unknown Source)
    at com.sun.javafx.collections.VetoableObservableList.setAll(Unknown Source)
    at com.sun.javafx.collections.ObservableListWrapper.setAll(Unknown Source)
    at com.sun.javafx.scene.control.skin.LabeledSkinBase.updateChildren(Unknown Source)
    at com.sun.javafx.scene.control.skin.LabeledSkinBase.handleControlPropertyChanged(Unknown Source)
    at com.sun.javafx.scene.control.skin.SkinBase$4.changed(Unknown Source)
    at javafx.beans.value.WeakChangeListener.changed(Unknown Source)
    at com.sun.javafx.binding.ExpressionHelper$SingleChange.fireValueChangedEvent(Unknown Source)
    at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(Unknown Source)
    at javafx.beans.property.StringPropertyBase.fireValueChangedEvent(Unknown Source)
    at javafx.beans.property.StringPropertyBase.markInvalid(Unknown Source)
    at javafx.beans.property.StringPropertyBase.set(Unknown Source)
    at javafx.beans.property.StringPropertyBase.set(Unknown Source)
    at javafx.beans.property.StringProperty.setValue(Unknown Source)
    at javafx.scene.control.Labeled.setText(Unknown Source)
    at com.sun.javafx.scene.control.skin.ListViewSkin$12.updateItem(Unknown Source)
    at javafx.scene.control.ListCell.updateItem(Unknown Source)
    at javafx.scene.control.ListCell.access$000(Unknown Source)
    at javafx.scene.control.ListCell$5.onChanged(Unknown Source)
    at com.sun.javafx.scene.control.WeakListChangeListener.onChanged(Unknown Source)
    at com.sun.javafx.collections.ObservableListWrapper.callObservers(Unknown Source)
    at com.sun.javafx.collections.ObservableListWrapper.remove(Unknown Source)
    at com.sun.javafx.collections.ObservableListWrapper.remove(Unknown Source)
    at truechatter.RoomController.updateRemove(RoomController.java:45)
    at truechatter.Client.run(Client.java:78)

while initList() method works properly. Why?

  • 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-06-16T00:06:01+00:00Added an answer on June 16, 2026 at 12:06 am

    The UI can only be updated by the gui-thread.

    Use:

    // create JavaFX scene
    Platform.runLater(new Runnable() {
        public void run() {
            members.add(name);
        }
    });
    

    why the initialize() method works is probably because it is already invoked from FX application thread

    from javadoc link:

    public static void runLater(java.lang.Runnable runnable)
    

    Run the specified Runnable on the JavaFX Application Thread at some
    unspecified time in the future. This method, which may be called from
    any thread, will post the Runnable to an event queue and then return
    immediately to the caller. The Runnables are executed in the order
    they are posted. A runnable passed into the runLater method will be
    executed before any Runnable passed into a subsequent call to
    runLater.

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

Sidebar

Related Questions

I am developing an application. I am creating the Universal Application using the Single
I am little bit confused about creating universal application for iOS devices using Xcode
In previous versions of Xcode creating a window-based, universal application would populate the project
When creating a new project (universal iPhone/iPad) using Core Data, there's the usual appDelegate
I have created static library project using the line script files. Then I am
I am creating a universal ios 2D game using cocos2d. I have few images
I'm creating an universal application and my CCMenu appears just fine on both iPhone,
I am in process of creating a new universal application. Would it be bad
I'm creating a smart client application using .NET 3.5. A Winforms client connecting through
I am creating an universal application (run on iPad and iPhone). I want to

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.