JavaFx阶段未出现
我试图使舞台出现,但似乎没有加载任何内容。编译它不会显示错误,但不会加载任何内容。感谢您的帮助!谢谢 其中重要的一点是,当ran是JavaFX时,没有加载任何内容。完全我真的不明白这个节目出了什么问题JavaFx阶段未出现,java,javafx,Java,Javafx,我试图使舞台出现,但似乎没有加载任何内容。编译它不会显示错误,但不会加载任何内容。感谢您的帮助!谢谢 其中重要的一点是,当ran是JavaFX时,没有加载任何内容。完全我真的不明白这个节目出了什么问题 package EventClick; /** * Write a description of class databaseq here. * * @author (your name) * @version (a version number or a date) */ impo
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);