本文共 4397 字,大约阅读时间需要 14 分钟。
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); }}
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
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); }}
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/