我正在尝试使用JFXtras中的时间选择器功能,我已导入从此link下载的jfxtras jar文件,但我在构建应用程序时遇到错误,我不知道如何解决此问题。
import java.io.IOException;
import java.util.Calendar;
import java.util.Locale;
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import jfxtras.labs.scene.control.CalendarPicker;
import jxl.write.WriteException;
public class ExcelApplication extends Application {
@Override
public void start(Stage primaryStage) throws IOException {
CalendarPicker dateTime = new CalendarPicker();
dateTime.withCalendar(Calendar.getInstance());
dateTime.withShowTime(Boolean.TRUE);
dateTime.withLocale(Locale.ENGLISH);
dateTime.calendarProperty().addListener(new ChangeListener<Calendar>() {
@Override
public void changed(ObservableValue<? extends Calendar> ov, Calendar t, Calendar t1) {
System.out.println("Selected date: "+t1.getTime().toString());
}
});
StackPane root = new StackPane();
root.getChildren().add(dateTime);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("Date & Time from JFXtras 2.2");
primaryStage.setScene(scene);
primaryStage.show();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}
这是我在尝试构建应用程序时遇到的错误
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$156(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: com/sun/javafx/scene/control/skin/SkinBase
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at javafx.scene.control.Control.loadClass(Control.java:117)
at javafx.scene.control.Control.loadSkinClass(Control.java:699)
at javafx.scene.control.Control$4.invalidated(Control.java:659)
at javafx.beans.property.StringPropertyBase.markInvalid(StringPropertyBase.java:109)
at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:144)
at javafx.css.StyleableStringProperty.set(StyleableStringProperty.java:83)
at javafx.scene.control.Control$4.set(Control.java:651)
at javafx.css.StyleableStringProperty.applyStyle(StyleableStringProperty.java:69)
at javafx.css.StyleableStringProperty.applyStyle(StyleableStringProperty.java:45)
at javafx.scene.CssStyleHelper.transitionToState(CssStyleHelper.java:774)
at javafx.scene.Node.impl_processCSS(Node.java:9189)
at javafx.scene.Parent.impl_processCSS(Parent.java:1241)
at javafx.scene.control.Control.impl_processCSS(Control.java:855)
at javafx.scene.Parent.impl_processCSS(Parent.java:1272)
at javafx.scene.Node.processCSS(Node.java:9056)
at javafx.scene.Scene.doCSSPass(Scene.java:545)
at javafx.scene.Scene.preferredSize(Scene.java:1643)
at javafx.scene.Scene.impl_preferredSize(Scene.java:1720)
at javafx.stage.Window$9.invalidated(Window.java:846)
at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:109)
at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:144)
at javafx.stage.Window.setShowing(Window.java:922)
at javafx.stage.Window.show(Window.java:937)
at javafx.stage.Stage.show(Stage.java:259)
at excel.application.ExcelApplication.start(ExcelApplication.java:67)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$163(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$176(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$174(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$175(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$149(WinApplication.java:191)
... 1 more
Caused by: java.lang.ClassNotFoundException: com.sun.javafx.scene.control.skin.SkinBase
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 58 more
Exception running application excel.application.ExcelApplication
Java Result: 1