V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  Forfaiting  ›  全部回复第 1 页 / 共 1 页
回复总数  1
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   ·   实用小工具   ·   2528 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 12ms · UTC 02:31 · PVG 10:31 · LAX 18:31 · JFK 21:31
Developed with CodeLauncher
♥ Do have faith in what you're doing.