i want to change the cirecle color all the time the COUNTER is smaller than 3 and while i waiting to click button. When the the cirecle is red he need to push on 'Stop'. This is the program:
public class Q1_2 extends Application {
private MyCircle circle = MyCircle.getInstance();
public int COUNTER;
public Color CURRENT_COLOR;
public Color currentColor;
public static void main(String[] args) {
launch();
}
@Override
public void start(Stage primaryStage) throws Exception {
circle.setRadius(100);
RadioButton bColor = new RadioButton("Stop");
COUNTER = 0;
HBox box = new HBox(40, bColor);
box.setPadding(new Insets(30));
StackPane pane = new StackPane(circle, box);
Scene scene = new Scene(pane, 500, 500);
primaryStage.setScene(scene);
primaryStage.show();
bColor.setOnAction(e -> {
if (bColor.isSelected() == true && currentColor != javafx.scene.paint.Color.RED) {
COUNTER++;
bColor.setSelected(false);
}
if (bColor.isSelected() == true && currentColor == javafx.scene.paint.Color.RED)
System.out.println("GREAT");
});
while (COUNTER < 3) {
currentColor = chooseColor();
circle.setFill(currentColor);
if (COUNTER == 3)
System.out.println("YOU LOSE");
}
}
}
Thank you!