忍者ブログ

からすまる日誌

今日の最後のコード exe19,exe20

×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

今日の最後のコード exe19,exe20

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();
 }
}
PR

コメント

ブログ内検索

カレンダー

03 2025/04 05
S M T W T F S
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30