Forum Stats

  • 3,872,464 Users
  • 2,266,426 Discussions
  • 7,911,213 Comments

Discussions

Cannot disable javafx.scene.text.Text

csh
csh Member Posts: 525
edited Sep 1, 2016 11:58AM in JavaFX 2.0 and Later

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();

  }

}

Answers

This discussion has been closed.