博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
《Java语言程序设计与数据结构》编程练习答案(第十四章)
阅读量:4170 次
发布时间:2019-05-26

本文共 4397 字,大约阅读时间需要 14 分钟。

《Java语言程序设计与数据结构》编程练习答案(第十四章)

英文名:Introduction to Java Programming and Data Structures, Comprehensive Version, 11th Edition

P4

import javafx.application.Application;import javafx.fxml.FXMLLoader;import javafx.geometry.Orientation;import javafx.scene.Parent;import javafx.scene.Scene;import javafx.scene.layout.FlowPane;import javafx.scene.paint.Color;import javafx.scene.paint.Paint;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 Main extends Application {
@Overridepublic void start(Stage primaryStage) throws Exception{
FlowPane pane = new FlowPane(); pane.setOrientation(Orientation.HORIZONTAL); for(int i=0;i<5;i++){
Text tmp = new Text("Java"); tmp.setFont(Font.font("Times New Roman", FontWeight.BLACK, FontPosture.ITALIC,22)); Color jj = new Color(Math.random(),Math.random(),Math.random(),Math.random()); tmp.setFill(jj); tmp.setRotate(90); pane.getChildren().add(tmp); } //pane.setRotate(90); Scene scene = new Scene(pane); primaryStage.setTitle("problem 14.4"); primaryStage.setScene(scene); primaryStage.show();}public static void main(String[] args) {
launch(args); }}

P5

import javafx.application.Application;import javafx.fxml.FXMLLoader;import javafx.scene.Parent;import javafx.scene.Scene;import javafx.scene.layout.Pane;import javafx.scene.layout.StackPane;import javafx.scene.text.Text;import javafx.stage.Stage;public class Main extends Application {
@Override public void start(Stage primaryStage) throws Exception{
Pane pane = new StackPane(); String target = "WELCOME TO JAVA "; for(int i=0;i

P6

mport javafx.application.Application;import javafx.fxml.FXMLLoader;import javafx.scene.Parent;import javafx.scene.Scene;import javafx.scene.layout.Pane;import javafx.scene.paint.Color;import javafx.scene.shape.Rectangle;import javafx.stage.Stage;public class Main extends Application {
@Override public void start(Stage primaryStage) throws Exception{
Pane pane = new Pane(); for(int i=0;i<8;i++){
for(int j=0;j<8;j++){
Rectangle tmp = new Rectangle(); tmp.xProperty().bind(pane.widthProperty().divide(8).multiply(j)); tmp.yProperty().bind(pane.heightProperty().divide(8).multiply(i)); tmp.widthProperty().bind(pane.widthProperty().divide(8)); tmp.heightProperty().bind(pane.heightProperty().divide(8)); if((i%2==0&&j%2==0)||(i%2==1&&j%2==1)) tmp.setFill(Color.WHITE); else tmp.setFill(Color.BLACK); pane.getChildren().add(tmp); } } Scene scene = new Scene(pane); primaryStage.setScene(scene); primaryStage.setTitle("Problem 14.6"); primaryStage.show(); } public static void main(String[] args) {
launch(args); }}

P7

import javafx.application.Application;import javafx.fxml.FXMLLoader;import javafx.scene.Parent;import javafx.scene.Scene;import javafx.scene.control.TextField;import javafx.scene.layout.Pane;import javafx.scene.paint.Color;import javafx.scene.shape.Rectangle;import javafx.stage.Stage;public class Main extends Application {
@Override public void start(Stage primaryStage) throws Exception{
Pane pane = new Pane(); for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
//rectangle tmp = new Rectangle();\ TextField tmp = new TextField(); //tmp.set().bind(pane.widthProperty().divide(8).multiply(j)); //tmp.yProperty().bind(pane.heightProperty().divide(8).multiply(i)); tmp.setLayoutX(40*j+5); tmp.setLayoutY(25*i+5); tmp.setMaxWidth(40); tmp.setMaxHeight(10); tmp.setText((int)(Math.random()*2)+""); tmp.setCenterShape(true); pane.getChildren().add(tmp); } } Scene scene = new Scene(pane); primaryStage.setScene(scene); primaryStage.setTitle("Problem 14.6"); primaryStage.show(); } public static void main(String[] args) {
launch(args); }}

算了算了,javafx真恶心,我还是用swing吧

转载地址:http://fywai.baihongyu.com/

你可能感兴趣的文章
python is 同一性运算符
查看>>
python basestring( )
查看>>
python 本地数据获取
查看>>
python write( )函数
查看>>
python read( )函数
查看>>
python readline()函数
查看>>
python readlines()函数
查看>>
python writelines()函数
查看>>
python 文件读写5个实例
查看>>
python 文件读写项目实践
查看>>
python的 os 和 shutil 模块
查看>>
python 如何反转序列
查看>>
python str.join()
查看>>
python 内置函数 reversed()
查看>>
python sort()方法
查看>>
python sorted()函数
查看>>
python reverse()方法
查看>>
Python sort( ) sorted( ) reverse( ) reversed( ) 总结
查看>>
python 工厂函数
查看>>
python 序列类型可用的内建函数
查看>>