Forfaiting 最近的时间轴更新
Forfaiting

Forfaiting

V2EX 第 297387 号会员,加入于 2018-03-06 22:39:18 +08:00
Forfaiting 最近回复了
2018-03-16 00:08:02 +08:00
回复了 buaashn 创建的主题 Java 求教 JavaFX 界面方面的问题
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class ABC extends Application {
private VBox root;
private VBox updown;
private StackPane upAB;
private StackPane downA;
private StackPane upC;
private StackPane downC;
private StackPane downB;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) {
HBox headBtns = new HBox();
Button btnA = new Button("A");
btnA.setOnAction(e -> updown.getChildren().setAll(upAB, downA));
Button btnB = new Button("B");
btnB.setOnAction(e -> updown.getChildren().setAll(upAB, downB));
Button btnC = new Button("C");
btnC.setOnAction(e -> updown.getChildren().setAll(upC, downC));
headBtns.getChildren().addAll(btnA, btnB, btnC);
updown = new VBox();
upAB = new StackPane();
upAB.setStyle("-fx-background-color: #FF0000");
upAB.getChildren().add(new Text("A&B"));
downA = new StackPane();
downA.setStyle("-fx-background-color: #007FFF");
downA.getChildren().add(new Text("A&B: A"));
downB = new StackPane();
downB.setStyle("-fx-background-color: #00FF7F");
downB.getChildren().add(new Text("A&B: B"));
upC = new StackPane();
upC.setStyle("-fx-background-color: #D9D919");
upC.getChildren().add(new Text("C"));
downC = new StackPane();
downC.setStyle("-fx-background-color: #CD7F32");
downC.getChildren().add(new Text("C"));
updown.getChildren().addAll(upAB, downA);
root = new VBox();
root.getChildren().addAll(headBtns, updown);
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
}
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2168 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 11ms · UTC 05:02 · PVG 13:02 · LAX 22:02 · JFK 01:02
Developed with CodeLauncher
♥ Do have faith in what you're doing.