JavaFX Tutorial 10 - CheckBox Java GUI

Опубликовано: 20 Октябрь 2024
на канале: Code Amir
667
7

JavaFX Tutorial 10 CheckBox Java GUI
Code Source :
@Override
public void start(Stage primaryStage) {
HBox h = new HBox();
CheckBox c1 = new CheckBox("USA");
c1.setSelected(true);
c1.setTextFill(Color.RED);
CheckBox c2 = new CheckBox("CANADA");
c2.setTextFill(Color.BLUE);
CheckBox c3 = new CheckBox("FRANCE");
c3.setTextFill(Color.GREEN);
h.getChildren().addAll(c1,c2,c3);

Scene sc = new Scene(h,600,400);
primaryStage.setScene(sc);
primaryStage.setTitle("Tutorial JavaFX");
primaryStage.show();
}
Libraries Importing:
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.CheckBox;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.stage.Stage;

A JavaFX CheckBox is a button which can be in three different states: Selected, not selected and unknown (indeterminate). The JavaFX CheckBox control is represented by the class javafx.scene.control.CheckBox.