ImageVerifierCode 换一换
格式:DOCX , 页数:135 ,大小:113.79KB ,
资源ID:10668914      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-10668914.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(《Java语言程序设计基础篇》第10版梁勇著第十五章练习题答案.docx)为本站会员(b****3)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

《Java语言程序设计基础篇》第10版梁勇著第十五章练习题答案.docx

1、Java语言程序设计基础篇第10版梁勇著第十五章练习题答案Java语言程序设计(基础篇)(第10版梁勇著)第十五章练习题答案15.1import javafx.application.Application;import javafx.geometry.Pos;import javafx.scene.Scene;import javafx.scene.control.Button;import javafx.scene.image.ImageView;import javafx.scene.layout.BorderPane;import javafx.scene.layout.HBox;im

2、port javafx.stage.Stage;import java.util.ArrayList;public class Exercise15_01 extends Application Override/ Override the start method in the Application classpublic void start(Stage primaryStage) / There are two ways for shuffling. One is to use the hint in the book./ The other way is to use the sta

3、tic shuffle method in the java.util.Collections class.ArrayList list = new ArrayList();for ( int i = 1; i java.util.Collections.shuffle(list);hBox.getChildren().clear();hBox.getChildren().add(new ImageView(image/card/+ list.get(0) +.png );hBox.getChildren().add(new ImageView(image/card/+ list.get(1)

4、 +.png );hBox.getChildren().add(new ImageView(image/card/+ list.get(2) +.png );hBox.getChildren().add(new ImageView(image/card/+ list.get(3) +.png ););new BorderPane();BorderPane pane = pane.setCenter(hBox);pane.setBottom(btRefresh);BorderPane.setAlignment(btRefresh, Pos.TOP_CENTER);/ Create a scene

5、 and place it in the stageScene scene = new Scene(pane, 250, 150);primaryStage.setTitle( Exercise15_01 ); / Set the stage titleprimaryStage.setScene(scene); / Place the scene in the stageprimaryStage.show(); / Display the stage/*The main method is only needed for the IDE with limited*JavaFX support.

6、 Not needed for running from the command line.*/public static void main(String args) launch(args);15.1 附加import import import import import import import import importjavafx.application.Application;javafx.geometry.Pos;javafx.scene.Scene;javafx.scene.control.Button;javafx.scene.layout.BorderPane; jav

7、afx.scene.layout.GridPane; javafx.scene.text.Font;javafx.scene.text.Text;javafx.stage.Stage;public class Exercise15_01Extra extends Application private Text texts = new Text1010;Override / Override the start method in the Application class public void start(Stage primaryStage) / Create UIGridPane pa

8、ne = new GridPane();pane.setAlignment(Pos.CENTER);pane.setHgap(10);pane.setVgap(10);for ( int i = 0; i 10; i+) for ( int j = 0; j for ( int i = 0; i 10; i+) for ( int j = 0; j if (getText().equals( H ) setText( T ); else setText( H ); );/*The main method is only needed for the IDE with limited*JavaF

9、X support. Not needed for running from the command line.*/public static void main(String args) launch(args);15.2import javafx.application.Application;import javafx.geometry.Pos;import javafx.scene.Scene;import javafx.scene.control.Button;import javafx.scene.layout.BorderPane;import javafx.scene.layo

10、ut.StackPane;import javafx.scene.paint.Color;import javafx.scene.shape.Rectangle;import javafx.stage.Stage;public class Exercise15_02 extends Application private double angle = 0;Override/ Override the start method in the Application class public void start(Stage primaryStage) StackPane stackPane =

11、new StackPane();Rectangle rectangle = new Rectangle(30, 30, 30, 60);rectangle.setFill(Color.WHITE);rectangle.setStroke(Color.BLACK);stackPane.getChildren().add(rectangle);/ Create a buttonButton btRotate = new Button( Rotate );btRotate.setOnAction(e - angle += 15;rectangle.setRotate(angle););BorderP

12、ane pane = new BorderPane();pane.setCenter(stackPane);pane.setBottom(btRotate);BorderPane.setAlignment(btRotate, Pos.TOP_CENTER);/ Create a scene and place it in the stageScene scene = new Scene(pane, 200, 150);primaryStage.setTitle( Exercise15_02 ); / Set the stage titleprimaryStage.setScene(scene)

13、; / Place the scene in the stageprimaryStage.show(); / Display the stage/*The main method is only needed for the IDE with limited*JavaFX support. Not needed for running from the command line.*/public static void main(String args) launch(args);15.2附加importjavafx.application.Application;importjavafx.g

14、eometry.Pos;importjavafx.scene.Scene;importjavafx.scene.control.Button;importjavafx.scene.layout.BorderPane;importjavafx.scene.layout.Pane;importjavafx.scene.shape.Line;importjavafx.stage.Stage;publicclass Exercise15_02Extraextends Application privatestaticPane pane = new Pane();privatestaticdouble

15、paneWidth = 400;privatestaticdouble paneHeight = 250;Override / Override the start method in the Application class public void start(Stage primaryStage) drawARandomArrowLine();Button btDrawArrowLine = new Button( Draw a random arrow line );BorderPane borderPane = new BorderPane();borderPane.setCente

16、r(pane);borderPane.setBottom(btDrawArrowLine);BorderPane.setAlignment(btDrawArrowLine, Pos.CENTER);btDrawArrowLine.setOnAction(e - drawARandomArrowLine();/ Create a scene and place it in the stageScene scene = new Scene(borderPane, 400, 250);primaryStage.setTitle( Exercise15_02 ); / Set the stage ti

17、tleprimaryStage.setScene(scene); / Place the scene in the stageprimaryStage.show(); / Display the stageprivate static void drawARandomArrowLine() pane.getChildren().clear();double x1 = Math.random() * (paneWidth - 12);double y1 = Math.random() * (paneHeight - 12);double x2 = Math.random() * (paneWid

18、th - 12);double y2 = Math.random() * (paneHeight - 12);drawArrowLine(x1, y1, x2, y2, pane);public static void drawArrowLine( double x1, double y1, double x2, double y2, Pane pane) pane.getChildren().add( new Line(x1, y1, x2, y2);/ find slope of this line double slope = ( double ) y1) - ( double ) y2

19、)/ ( double ) x1) - ( double ) x2);double arctan = Math.atan(slope);/ This will flip the arrow 45 off of a/ perpendicular line at pt x2double set45 = 1.57 / 2;/ arrows should always point towards i, not i+1if (x1 circle.setCenterX(circle.getCenterX() 0 ? circle.getCenterX() - 2 : 0););btRight.setOnAction(e - circle.setCenterX(circle.getCenterX() circle.setCenterY(circle.getCenterY() 0 ? circle.getCenterY() - 2 : 0););btDown.setOnAction(e - circle.setCenterY(circle.getCe

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2