梁勇java程序设计基础答案

梁勇java程序设计基础答案Java 语言程序设计 基础篇 第 10 版梁勇著 第十五章练习题答案 15 1 importjavafx application Application importjavafx geometry Pos importjavafx scene Scene importjavafx scene control Button importjavafx scene image

大家好,我是讯享网,很高兴认识大家。



Java语言程序设计(基础篇)》(第10版梁勇著)

第十五章练习题答案

15.1

importjavafx.application.Application;

importjavafx.geometry.Pos;

importjavafx.scene.Scene;

importjavafx.scene.control.Button;

importjavafx.scene.image.ImageView;

importjavafx.scene.layout.BorderPane;

importjavafx.scene.layout.HBox;

i梁勇java程序设计基础答案mportjavafx.stage.Stage;

importjava.util.ArrayList;

publicclassExercise15_01extendsApplication{

@Override

//OverridethestartmethodintheApplicationclass

publicvoidstart(StageprimaryStage){

//Therearetwowaysforshuffling.Oneistousethehintinthebook.

//Theotherwayistousethestaticshufflemethodinthe

java.util.Collectionsclass.

ArrayListIntegerlist=newArrayList();

for(inti=1;i=52;i++){

list.add(i);

}

java.util.Collections.shuffle(list);

HBoxhBox=newHBox(5);

hBox.setAlignment(Pos.CENTER);

hBox.getChildren().add(newImageView(ImageView(+list.get(0)++list.get(0)+

));

hBox.getChildren().add(newImageView(ImageView(+list.get(1)++list.get(1)+

));

hBox.getChildren().add(newImageView(ImageView(+list.get(2)++list.get(2)+

));

hBox.getChildren().add(newImageView(ImageView(+list.get(3)++list.get(3)+

));

//Createabutton

ButtonbtRefresh=newButton(Button();

btRefresh.setOnAction(e-{

java.util.Collections.shuffle(list);

hBox.getChildren().clear();

hBox.getChildren().add(newImageView(ImageView(+list.get(0)++list.get(0)+

));

小讯
上一篇 2025-01-01 19:29
下一篇 2025-01-01 13:02

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/9000.html