gpt4 book ai didi

JavaFx 阶段未出现

转载 作者:行者123 更新时间:2023-12-02 11:48:26 25 4
gpt4 key购买 nike

我正在尝试显示一个舞台,但似乎没有任何内容正在加载。编译它没有显示任何错误,但不会加载任何内容。任何帮助表示赞赏!谢谢! :)其中最重要的部分是,当运行 JavaFX 时,没有加载任何内容。完全没有。我真的不明白这个程序出了什么问题。

package EventClick;


/**
* Write a description of class databaseq here.
*
* @author (your name)
* @version (a version number or a date)
*/
import EventClick.adminLogin.*;
import javafx.application.*;
import javafx.stage.*;
import javafx.scene.*;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.geometry.*;
import java.util.*;
import javafx.util.Duration;
import javafx.animation.PauseTransition;

public class databaseq extends Application {
Stage stage;
Stage stage2;

@Override public void start(Stage primaryStage) {
stage = primaryStage;
Platform.setImplicitExit(false);
//Create Login Button
Button loginbtn = new Button();
loginbtn.setText("Login");
loginbtn.setOnAction(e -> loginOn_Click());

//Create Credentials Button
Button credbtn = new Button();
credbtn.setText("Credentials");
credbtn.setOnAction(e -> credOn_Click());

//Create Close Button
Button closebtn = new Button();
closebtn.setText("Quit");
closebtn.setOnAction(e -> closeOn_Click());
//Add buttons to a layout pane
VBox pane = new VBox(10);
pane.getChildren().addAll(loginbtn, credbtn, closebtn);
pane.setAlignment(Pos.CENTER);

//Add layout pane to a scene
Scene scene = new Scene(pane, 250, 150);
Scene scene2 = new Scene(pane, 250, 150);
//Finish and show the scene

primaryStage.setScene(scene);
primaryStage.setTitle("Test Server");
primaryStage.show();
}

public void loginOn_Click() {
Alert a = new Alert(Alert.AlertType.CONFIRMATION,"Do you want to log in?",
ButtonType.YES, ButtonType.NO);
Optional<ButtonType> confirm = a.showAndWait();
if(confirm.isPresent() && confirm.get() == ButtonType.YES) {

}
}
public void credOn_Click() {
Alert a = new Alert(Alert.AlertType.INFORMATION);
a.setTitle("Test Server");
a.setHeaderText("Loading Credentials...");
a.setContentText("Entering User Login Server");

a.showAndWait();
}

public void closeOn_Click() {
Alert a = new Alert(Alert.AlertType.CONFIRMATION,"Are you sure you want to quit?",
ButtonType.YES, ButtonType.NO);
Optional<ButtonType> confirm = a.showAndWait();
if(confirm.isPresent() && confirm.get() == ButtonType.YES) {
stage.close();
}
}
}

最佳答案

 //Add layout pane to a scene
Scene scene = new Scene(pane, 250, 150);
Scene scene2 = new Scene(pane, 250, 150);

这是搞乱程序的代码。由于某种原因,同时加载两个场景会弄乱显示。

关于JavaFx 阶段未出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48047505/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com