2017-07-10 23 views
0

私はDatePickerを持っており、このリスナーを追加しています。"選択された"スタイルを適用した後、DateCellが変更されない

DatePickerを表示して日付を選択すると、1つのセルだけが選択されて表示されます。

DatePicker with one day selected

スタイルはすべて、「選択」しているコンソールにプリントアウトが、何セルウィッヒが実際に選択されていること、疑問に私を続けていること2「選択」のスタイルを持っているにも厳しいです。 これは、コンソール出力(その一部)である:

cell date-cell day-cell selected Day: 2017-07-11 
cell date-cell day-cell selected Day: 2017-07-12 
cell date-cell day-cell selected selected Day: 2017-07-13 
cell date-cell day-cell selected Day: 2017-07-14 
cell date-cell day-cell selected Day: 2017-07-15 

選択として、なぜ一つだけのセルが表示されていますか?

+0

私は他の質問にリンクする方法がわからない、どちらもウェブ... – KarlTheGreat

+0

https://stackoverflow.com/questions/27229168/selecting-a-period-にその上のすべてのリソースを見つけることができませんまたは-a-date-using-one-javafx-8-datepicker – KarlTheGreat

答えて

0

リスナーをプロパティに追加しないでください。ちょうどdatePicker.onShownに設定してください。

//Get the content 
datePicker.onShown(e -> { 
     DatePickerContent content = (DatePickerContent)((DatePickerSkin)datePicker.getSkin()).getPopupContent(); 
     content.lookupAll(".day-cell").forEach(cell -> { 
      cell.getStyleClass().add("selected"); 
     }); 
} 
関連する問題