我有个问题-
我需要换个场景。我在主文件中拥有的阶段和根场景:
package sample;
public class Main extends Application {
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(Objects.requireNonNull(
getClass().getResource("scenses/sample.fxml")));
stage.setTitle("BlogApp");
stage.setScene(new Scene(root, 600, 400));
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
同样我有控制器,有登录按钮。只有(找到用户)才会登录,并且场景必须更改为主场景:
button_auth.setOnAction(event -> {
login_auth.setStyle("-fx-border-color: #fafafa");
pass_auth.setStyle("-fx-border-color: #fafafa");
button_reg.setText("Sign Up");
if (login_auth.getCharacters().length() < 3) {
login_reg.setStyle("-fx-border-color: red");
return;
} else if (pass_auth.getCharacters().length() < 3) {
pass_auth.setStyle("-fx-border-color: red");
return;
}
String pass = md5String(pass_auth.getCharacters().toString());
try {
boolean isAuth = db.authUser(login_auth.getCharacters().toString(), pass);
if (isAuth) {
login_auth.setText("");
pass_auth.setText("");
button_auth.setText("Logged in");
Parent root = FXMLLoader.load(Objects.requireNonNull(
getClass().getResource("scenses/secondScene.fxml")));
Scene homepage_scene = new Scene(root);
Stage window = (Stage) ((Node) event.getSource()).getScene().getWindow();
window.setScene(homepage_scene);
window.show();
} else {
button_auth.setText("Login is denied");
}
} catch (SQLException | ClassNotFoundException | IOException e) {
e.printStackTrace();
}
});
这给了我一个错误:
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at java.base/java.util.Objects.requireNonNull(Objects.java:221)
at sample.controllers.regController.lambda$initialize$1(regController.java:114)
at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
at javafx.graphics/javafx.scene.Node.fireEvent(Node.java:8889)
at javafx.controls/javafx.scene.control.Button.fire(Button.java:203)
at javafx.controls/com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:208)
at javafx.controls/com.sun.javafx.scene.control.inputmap.InputMap.handle(InputMap.java:274)
at javafx.base/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:247)
at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:234)
at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.base/javafx.event.Event.fireEvent(Event.java:198)
at javafx.graphics/javafx.scene.Scene$MouseHandler.process(Scene.java:3856)
at javafx.graphics/javafx.scene.Scene.processMouseEvent(Scene.java:1851)
at javafx.graphics/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2584)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:409)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:299)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$2(GlassViewEventHandler.java:447)
at javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:412)
at javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:446)
at javafx.graphics/com.sun.glass.ui.View.handleMouseEvent(View.java:556)
at javafx.graphics/com.sun.glass.ui.View.notifyMouse(View.java:942)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)
错误线114为
Parent root = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("scenses/secondScene.fxml")));
我刚来Java,所以我真不明白为什么会这样。不管怎么说都是求救。
其实我不太明白你想做什么。但您给出了错误的getResource路径。这就是为什么你不能得到你想要达到的目标而得到一个NullPointerExcepiton的原因。你能更新如下吗?你能写作为一个评论,如果它是有效的吗?
Parent root = FXMLLoader.load(Objects.requireNonNull(
getClass().getResource("sample.fxml")));
我有个问题- 我需要换个场景。我在主文件中拥有的阶段和根场景: 同样我有控制器,有登录按钮。只有(找到用户)才会登录,并且场景必须更改为主场景: 这给了我一个错误: 错误线114为 我刚来Java,所以我真不明白为什么会这样。不管怎么说都是求救。
当我尝试使用JQuery POST向服务器发送数据时,我得到以下错误。 我做错了什么? 未捕获的TypeError:在e处非法调用(https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js:4:7727)在Ab(https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.
我已经安装了用于PHP开发的XAMPPv3.2.1。由于我已经安装了Skype并使用端口80和443,我将XAMPP配置为在端口1333(http.conf)和3333(https.conf)上运行。 我启动了xampp MySQL服务并成功启动。 当我导航到超文本传输协议://: 1333 xampp工作正常,但是如果我点击phpmyadmin我得到以下错误。 MySQL说:文档 服务器没有响应
为了参考,我的“jps”命令的输出结果是
因此,我使用服务器(google-app-engine)在客户端应用程序上进行身份验证。当我使用JavaFX、Webview或HttpsURLConnection时,一切都很好,它们连接起来了,但是当我使用HttpClient时,它会抛出以下错误 javax.net.ssl.sslpeerunverifiedexception:peer未在sun.security.ssl.sslsessionim
问题内容: 我有以下代码: 但是,它引发此错误: 谁能告诉我为什么会这样吗? 问题答案: 我相信这是因为相对的路径。“ ../”被认为是恶意的。首先解析本地路径,然后调用。您可以事先解析路径。