fxml檔中包含event事件類別 SMSevent
錯誤訊息 : java.lang.IllegalAccessException: Class javafx.fxml.FXMLLoader$ValueElement can not access a member of class JavaFXAppTest.SMSevent with modifiers ""
file:/C:/Users/DogKing/Documents/NetBeansProjects/JavaFXAppTest/dist/JavaFXAppTest.jar!/JavaFXAppTest/sms.fxml:13
at javafx.fxml.FXMLLoader$ValueElement.processValue(FXMLLoader.java:661)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:572)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2314)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2131)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2028)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2742)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2721)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2707)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2694)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2683)
at JavaFXAppTest.MyFXML.start(MyFXML.java:23)
at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:206)
at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
at java.lang.Thread.run(Thread.java:722)
Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:403)
at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.RuntimeException: java.lang.IllegalAccessException: Class javafx.fxml.FXMLLoader$ValueElement can not access a member of class JavaFXAppTest.SMSevent with modifiers ""
at javafx.fxml.FXMLLoader$ValueElement.processValue(FXMLLoader.java:661)
at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:572)
at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2314)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2131)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2028)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2742)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2721)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2707)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2694)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2683)
at JavaFXAppTest.MyFXML.start(MyFXML.java:23)
at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:206)
at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:173)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
... 1 more
Caused by: java.lang.IllegalAccessException: Class javafx.fxml.FXMLLoader$ValueElement can not access a member of class JavaFXAppTest.SMSevent with modifiers ""
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:95)
at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:261)
at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:253)
at java.lang.reflect.Field.doSecurityCheck(Field.java:983)
at java.lang.reflect.Field.getFieldAccessor(Field.java:927)
at java.lang.reflect.Field.set(Field.java:680)
at javafx.fxml.FXMLLoader$ValueElement.processValue(FXMLLoader.java:659)
... 17 more
Java Result: 1
jfxsa-run:
BUILD SUCCESSFUL (total time: 6 seconds)
我覺得主要是紅色部分那裏需要解決
-------------------------------------------------------------------
以下為主程式:
package JavaFXAppTest;
import javafx.fxml.FXML;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class MyFXML extends Application {
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("sms.fxml")); //載入fxml檔,所有UI介面設定都在 //fxml檔裡