Java语言程序设计与数据结构(基础篇)课后练习题 第十四章

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);

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值