Forfaiting's recent timeline updates
Forfaiting

Forfaiting

V2EX member #297387, joined on 2018-03-06 22:39:18 +08:00
Forfaiting's recent replies
Mar 16, 2018
Replied to a topic by 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();
}
}
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5475 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 13ms · UTC 06:43 · PVG 14:43 · LAX 23:43 · JFK 02:43
♥ Do have faith in what you're doing.