Assuming the appropriate supporting code is provided, what will the following co
ID: 3863666 • Letter: A
Question
Assuming the appropriate supporting code is provided, what will the following code segment display? EventHandler<ActionEvent> eventHandler = e-> { if (text.getText().equals("Green")) { text.setText("Red"); text.setFill(Color.RED); }
else { text.setText("Green"); text.setFill(Color.GREEN); }
};
// Create an animation for alternating text
Timeline animation = new Timeline(
new KeyFrame(Duration.millis(5000), eventHandler));
animation.setCycleCount(Timeline.INDEFINITE);
animation.play(); // Start animation
Explanation / Answer
The code segment will change the text to "Red" and "Green" alternatively. As well set the color matching the Text.