java语言程序设计基础篇第十版第十四章练习答案.docx
01 import javafx.application.Application; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.layout.GridPane; import javafx.stage.Stage; import javafx.scene.image.ImageView; public class rcise14_01 extends Application Override Override the start in the Application class public void startStage primaryStage GridPane pane new GridPane; pane.setAlignmentPos.CENTER; pane.setHgap5; pane.setVgap5; ImageView imageView1 new ImageView“image/uk.gif“; ImageView imageView2 new ImageView“image/ca.gif“; ImageView imageView3 new ImageView“image/china.gif“; ImageView imageView4 new ImageView“image/us.gif“; pane.addimageView1, 0, 0; pane.addimageView2, 1, 0; pane.addimageView3, 0, 1; pane.addimageView4, 1, 1; Create a scene and place it in the stage Scene scene new Scenepane; primaryStage.setTitle“rcise14_01“; Set the stage title primaryStage.setScenescene; Place the scene in the stage primaryStage.show; Display the stage / * The main is only needed for the IDE with limited * JavaFX support. Not needed for running from the command line. */ public static void mainString args launchargs; 02 import javafx.application.Application; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.layout.GridPane; import javafx.stage.Stage; import javafx.scene.image.ImageView; import javafx.scene.image.Image; public class rcise14_02 extends Application Override Override the start in the Application class public void startStage primaryStage Image imageX new Image“image/x.gif“; Image imageO new Image“image/o.gif“; GridPane pane new GridPane; pane.setAlignmentPos.CENTER; pane.setHgap5; pane.setVgap5; for int i 0; i list new ArrayList; for int i 1; i list polygon.getPoints; final double WIDTH 200, HEIGHT 200; double centerX WIDTH / 2, centerY HEIGHT / 2; double radius Math.minWIDTH, HEIGHT * 0.4; Add points to the polygon list for int i 0; i list polyline.getPoints; double scaleFactor 0.0125; for int x -100; x list1 polyline1.getPoints; polyline1.setStrokeColor.RED; Polyline polyline2 new Polyline; ObservableList list2 polyline2.getPoints; polyline2.setStrokeColor.BLUE; double scaleFactor 50; for int x -170; x list polygon.getPoints;