LoginSignup
1
0

More than 3 years have passed since last update.

[JavaFX]CheckBoxについて確認してみました。

Last updated at Posted at 2019-07-05

外観

checkbox.png

サンプルコード

package myapp.gui;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.CheckBox;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;

public class Main extends Application {
    public static void main( String[] args ) {
        Main.launch( args );
    }

    @Override
    public void start(Stage stage ) throws Exception {

        CheckBox cb = new CheckBox( "アイテム1" );

        Pane root = new Pane();
        root.getChildren().addAll( cb );

        stage.setTitle( "JavaFXサンプル(CheckBox)" );
        stage.setMinWidth( 400 );
        stage.setMinHeight( 300 );

        Scene scene = new Scene( root );
        stage.setScene( scene );

        stage.show();
    }
}

主なメソッド

  • setSelected( boolean b )
    ・ bにtrueを設定した場合、チェックボックスがチェックありの状態となる。
    ・ bにtrueを設定した場合、チェックボックスがチェックなしの状態となる。

  • isSelected()
    チェック有無を取得する。(true:チェックあり、false:チェックなし)

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0