Skip to Main Content

Cannot disable javafx.scene.text.Text

cshAug 26 2016 — edited Sep 1 2016

Hi.

I want to disable javafx.scene.text.Text in a Scene. These texts are contained in a TextFlow.

However, the Texts are not displayed as disabled (unlike Label). If I add javafx.scene.control.Label to the TextFlow instead, they are displayed gray (disabled).

How can I achieve the same visual representation with Texts (displaying it gray / opaque, when disabled)?

import javafx.application.Application;

import javafx.scene.Scene;

import javafx.scene.text.Text;

import javafx.scene.text.TextFlow;

import javafx.stage.Stage;

public class TestApp extends Application {

   public static void main(String[] args) {

   launch(args);

  }

   @Override
   public void start(final Stage stage) throws Exception {

  TextFlow textFlow = new TextFlow();

  textFlow.getChildren().add(new Text("test"));

  textFlow.disableProperty().set(true);

  Scene scene = new Scene(textFlow);

  stage.setScene(scene);

  stage.show();

  }

}

Comments
Post Details
Added on Aug 26 2016
2 comments
476 views