pane.add(imageView2, 0, 1);
pane.add(imageView3, 1, 1);
Scene scene = new Scene(pane);
primaryStage.setTitle(“Exercise14_01”);
primaryStage.setScene(scene);
primaryStage.show();
}
}
[](()14.2
=================================================================
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.image.ImageView;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
public class dishisizhang extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
GridPane pane = new GridPane();
pane.setPadding(new Insets(8, 8, 8, 8));
pane.setHgap(8);
pane.setVgap(8);
for (int column = 0; column < 3; column++)
for (int row = 0; row < 3; row++) {
int i = (int)(Math.random() * 3);
if (i != 2)
pane.add(getNode(i), column, row);
}
Scene scene = new Scene(pane);
primaryStage.setTitle(“Exercise14_02”);
primaryStage.setScene(scene);
primaryStage.show();
}
public ImageView getNode(int i) {
if (i == 0)
return new ImageView(“image/o.gif”);
else
return new ImageView(“image/x.gif”);
}
}
[](()14.3
=================================================================
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
public class dishisizhang extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
HBox pane = new HBox(5);
pane.setPadding(new Insets(5, 5, 5, 5));
Integer[] array = {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,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, 52};
ArrayList list = new ArrayList<>(Arrays.asList(array));
《一线大厂Java面试题解析+后端开发学习笔记+最新架构讲解视频+实战项目源码讲义》无偿开源 威信搜索公众号【编程进阶路】 Collections.shuffle(list);
ImageView p1 = new ImageView(“image/card/” + Integer.valueOf(list.get(0)) + “.png”);
ImageView p2 = new ImageView(“image/card/” + Integer.valueOf(list.get(1)) + “.png”);
ImageView p3 = new ImageView(“image/card/” + Integer.valueOf(list.get(2)) + “.png”);
pane.getChildren().addAll(p1, p2, p3);
Scene scene = new Scene(pane);
primaryStage.setTitle(“Exercose14_02”);
primaryStage.setScene(scene);
primaryStage.show();
}
}
[](()14.4
=================================================================
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class dishisizhang extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
HBox pane = new HBox(15);
pane.setPadding(new Insets(15, 15, 15, 15));
for (int i = 0; i < 5; i++)
pane.getChildren().add(getVBox());
Scene scene = new Scene(pane);
primaryStage.setTitle(“Wxercise14_04”);
primaryStage.setScene(scene);
primaryStage.show();
}
public VBox getVBox() {
VBox pane = new VBox();
Color color = new Color(Math.random(), Math.random(), Math.random(), Math.random());
Text lb = new Text(“Java”);
lb.setFont(Font.font(“TimesRomes”, FontWeight.BOLD, FontPosture.ITALIC, 22));
lb.setFill(color);
lb.setRotate(90);
pane.getChildren().add(lb);
return pane;
}
}
[](()14.5
=================================================================
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class dishisizhang extends Application {
public static void main(String[] args) {
launch(args);
}