我的项目在eclipse中正常运行但是当我创建这个项目的jar文件并尝试通过cmd运行时,它显示"Location not set set"错误.
我的项目结构是:
方法是(在eclipse中运行):
@FXML
private void RegularCustomer(ActionEvent event) throws Exception{
Stage stage = (Stage) dailySales.getScene().getWindow();
Scene scene = dailySales.getScene();
FXMLLoader loader = new FXMLLoader(getClass().getResource("../customer/CustomerHome.fxml"));
System.out.println(loader.getLocation());
scene.setRoot(loader.load());
stage.setScene(scene);
stage.show();
}
Run Code Online (Sandbox Code Playgroud)
这段代码有什么问题?
有一些相关问题,但它们有所不同.他们的代码不在IDE中运行,但我的代码在IDE中运行.
仅供参考:我对文件夹结构进行了一些更改,并且能够成功运行.但是这种结构很糟糕,因为我把所有的FXML文件和控制器放在同一个包中.
我面临着一个奇怪的问题.我有一个可编辑的ComboBox和一些项目.运行我的代码后如果我在ComboBox中键入内容并调用getValue()函数,那么它会给我null值.
这是我的代码(thenewboston):包应用程序;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class Main extends Application {
Stage window;
Scene scene;
Button button;
ComboBox<String> comboBox;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
window = primaryStage;
window.setTitle("ComboBox Demo");
button = new Button("Submit");
comboBox = new ComboBox<>();
comboBox.getItems().addAll(
"Good Will Hunting",
"St. Vincent",
"Blackhat"
);
comboBox.setPromptText("What is your favorite movie?");
comboBox.setEditable(true);
button.setOnAction(e -> printMovie()); …
Run Code Online (Sandbox Code Playgroud)