[英]JavaFx Stage not appearing
我正在嘗試顯示一個舞台,但似乎沒有加載任何內容。 編譯不會顯示任何錯誤,但是不會加載任何內容。 任何幫助表示贊賞! 謝謝! :)重要的一點是,當運行的是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);
這是使程序混亂的代碼。 由於某種原因,一次加載兩個場景會使顯示混亂。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.