Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

In Swing, we can disable a button like this:

JButton start = new JButton("Start");
start.setEnabled(false);

Is there anyway to do this with a JavaFX Button? The user should only be able to press the button once.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
326 views
Welcome To Ask or Share your Answers For Others

1 Answer

Of course. Only related property has opposite semantic and is called disabled. Which means you can use setDisable (not setDisabled) and isDisabled. Since it is a JavaFX property you can also attach listeners to disabledProperty.

Check out the JavaFX documentation at http://docs.oracle.com/javafx/2/api/javafx/scene/Node.html#setDisable(boolean)

Code

button.setDisable(false)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...