exe19.java
package application;
import javafx. application.Application;
import javafx.geometry.Pos;
import javafx. scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.FlowPane;
import javafx. stage.Stage;
/*
import javafx. scene.Group;
import javafx. scene.Scene;
import javafx. scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.image.Image;
import javafx.scene.paint.Color;
import javafx. stage.Stage;
*/
public class EXE19 extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage myStage) {
Label l1;//Label型変数l1を宣言
l1 = new Label("ラベル1");//Labelオブジェクトを生成し変数に代入
TextField tf1 = new TextField("文字入力できます");
Button b1 = new Button("ボタン1");//Buttonオブジェクトを生成し変数に代入
Button b2 = new Button("ボタン2");
FlowPane pane = new FlowPane();//FlowPaneオブジェクトを生成し変数に代入。flowpaneはどんどん横に並べる形
//丸括弧の中が空なのでぴちぴちにつめる
pane.setAlignment(Pos.TOP_LEFT);
pane.getChildren().add(l1);//ラベル1
pane.getChildren().add(tf1);//ラベル1
pane.getChildren().add(b1);//ボタン1
pane.getChildren().add(b2);//ボタン2
pane.setStyle("-fx-background-color:lightgray;");
Scene scene = new Scene(pane,350,50);//シーンのサイズ
myStage.setTitle("Exe19");
myStage.setScene(scene);
myStage.show();
}
}
--->
exe20.java
package application;
import javafx. application.Application;
import javafx.geometry.Pos;
import javafx. scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.FlowPane;
import javafx. stage.Stage;
/*
import javafx. scene.Group;
import javafx. scene.Scene;
import javafx. scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.image.Image;
import javafx.scene.paint.Color;
import javafx. stage.Stage;
*/
public class EXE20 extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage myStage) {
Label l1;//Label型変数l1を宣言
l1 = new Label("ラベル1");//Labelオブジェクトを生成し変数に代入
TextField tf1 = new TextField("文字入力できます");
Button b1 = new Button("ボタン1");//Buttonオブジェクトを生成し変数に代入
Button b2 = new Button("ボタン2");
FlowPane pane = new FlowPane(10,20);//内容物の隙間あり
pane.setAlignment(Pos.TOP_LEFT);
pane.getChildren().add(l1);//ラベル1
pane.getChildren().add(tf1);//ラベル1
pane.getChildren().add(b1);//ボタン1
pane.getChildren().add(b2);//ボタン2
pane.setStyle("-fx-background-color:lightgray;");
Scene scene = new Scene(pane,250,100);//シーンのサイズ
myStage.setTitle("Exe20");
myStage.setScene(scene);
myStage.show();
}
}