JavaFx阶段没有出现

时间:2018-01-01 06:06:42

标签: java javafx

我试图让一个舞台出现,但似乎没有任何东西加载。编译它会显示没有错误,但不会加载任何内容。任何帮助表示赞赏!谢谢! :) 其中很重要的一点是,当run是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();
        }
    }
}

1 个答案:

答案 0 :(得分:1)

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

这是弄乱程序的代码。由于某种原因,一次加载两个场景搞砸了显示器。