if(label.getText()=="你好!") {
label.setText("再见!");
}
else {
label.setText("你好!");
}
}
});
primaryStage.setTitle("you");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
// TODO 自动生成的方法存根
Application.launch(args);
}
}
//test2.java 外部类
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.FlowPane;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.stage.Stage;
public class test2 extends Application {
public Label label = new Label("你好!");
public void start(Stage primaryStage) {
// TODO 自动生成的方法存根
FlowPane pane =new FlowPane();
Button okButton = new Button("change");
pane.getChildren().add(okButton);
Scene scene = new Scene(pane,300,400);
label.setFont(Font.font("你
好",FontWeight.BOLD,FontPosture.ITALIC,20));
pane.getChildren().add(label);
评论0
最新资源