2017-01-08 6 views
1

いつも開いている(popup)datepickerを作成しようとしています.githububのリンクhttps://gist.github.com/flasheater/ba58d5adffa1324e727eから作業中のコードがあります。 しかし、私の問題は、コントローラクラスにこのコードを実装したときにerror.Soを表示しています。下の完全なコードを投稿したいと思います。JavaFX with always-visible-datepicker

FXMLDocumentController.java

public class FXMLDocumentController implements Initializable { 
    @FXML 
    private AnchorPane bp; 
    @Override 
    public void initialize(URL url, ResourceBundle rb) { 
    final DatePicker date_picker = new DatePicker(); 
    StackPane root=new StackPane(date_picker); 
    date_picker.setVisible(false); 
    date_picker.setManaged(false); 

    final com.sun.javafx.scene.control.skin.DatePickerSkin skin = (com.sun.javafx.scene.control.skin.DatePickerSkin) date_picker.getSkin(); 
    root.getChildren().add(skin.getPopupContent()); 
    //added to stackpane.I think above line is having problem 
    bp.getChildren().add(root); //added to anchorpane which already designed via scenebuilder 
} 
} 

(scenebuilder2.0を経由して設計された)FXMLDocument.fxml

<?xml version="1.0" encoding="UTF-8"?> 
<?import java.lang.*?> 
<?import java.util.*?> 
<?import javafx.scene.*?> 
<?import javafx.scene.control.*?> 
<?import javafx.scene.layout.*?> 

<AnchorPane fx:id="bp" prefHeight="443.0" prefWidth="563.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="tableviewmodalbaseview.FXMLDocumentController" /> 

とエラー

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 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.launchApplication(LauncherImpl.java:323) 
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$152(LauncherImpl.java:182) 
at com.sun.javafx.application.LauncherImpl$$Lambda$51/17398621.run(Unknown Source) 
at java.lang.Thread.run(Thread.java:745) 


Caused by: javafx.fxml.LoadException: 
    file:/C:/Users/aboosidhu/Documents/NetBeansProjects/TableViewModalBaseView/dist/run1705880335/TableViewModalBaseView.jar!/tableviewmodalbaseview/FXMLDocument.fxml 

at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2605) 
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2583) 
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2445) 
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3218) 
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3179) 
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3152) 
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3128) 
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3108) 
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3101) 
at tableviewmodalbaseview.TableCellFactorySample.start(TableCellFactorySample.java:46) 
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$159(LauncherImpl.java:863) 
at com.sun.javafx.application.LauncherImpl$$Lambda$54/31372366.run(Unknown Source) 
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$172(PlatformImpl.java:326) 
at com.sun.javafx.application.PlatformImpl$$Lambda$46/22256815.run(Unknown Source) 
at com.sun.javafx.application.PlatformImpl.lambda$null$170(PlatformImpl.java:295) 
at com.sun.javafx.application.PlatformImpl$$Lambda$49/23180581.run(Unknown Source) 
at java.security.AccessController.doPrivileged(Native Method) 
at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(PlatformImpl.java:294) 
at com.sun.javafx.application.PlatformImpl$$Lambda$48/265996.run(Unknown Source) 
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$145(WinApplication.java:101) 
at com.sun.glass.ui.win.WinApplication$$Lambda$37/23703675.run(Unknown Source) 
... 1 more 



Caused by: java.lang.NullPointerException 
at tableviewmodalbaseview.FXMLDocumentController.initialize(FXMLDocumentController.java:151) 
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2552) 
... 22 more 

を次のように誰もが私を修正するために助けることができます私のコード上のエラー。すべての答えは高く評価されます。

+0

'NullPointerException':インスタンス化の問題&これは何ですか' date_picker.getProperties().; '(あなたはこれをコンパイルできないというエラーはありません) –

+0

ああ、私は入力ミスで申し訳ありません。コードを編集しました。それはエラーの理由ではありませんでした。問題は、新しいシーンと新しいステージのdatepickerスキンを追加するときに問題になります。私の既存のfxmlファイルです。 –

+0

'FXMLDocumentController.java'の行151には何がありますか? –

答えて

1

私はあなたが達成したい内容を正確に把握していないが、私はここにCastを使用しての関心が表示されない:

final com.sun.javafx.scene.control.skin.DatePickerSkin skin = (com.sun.javafx.scene.control.skin.DatePickerSkin) date_picker.getSkin(); 

理由を引数としてあなたDatePickerと直接インスタンスを使用していない:

final DatePickerSkin skin = new DatePickerSkin(date_picker); 

コンポーネントを正しくインポートしようとすると、幸いです!

+0

wow.itは完璧に機能しました。そうです、鋳造が問題でした。あなたの努力に感謝します。 –

関連する問題