是否可以从场景构建器中显示日历控制器?我正在尝试显示一个理想情况下必须链接到数据属性和时间段的日历。有什么帮助吗?
问问题
2383 次
1 回答
1
我没有使用场景生成器,但您可以手动编辑 fxml 以添加 DatePicker。I created a simple example that shows a date picker and when the date is chosen it displays it in a Text field below.
fxml 看起来像:
<GridPane fx:controller="datepicker.DatePickerController" xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">
<padding>
<Insets top="25" right="25" bottom="10" left="25" />
</padding>
<DatePicker fx:id="datepicker" GridPane.columnIndex="0" GridPane.rowIndex="0" onAction="#handleDatePickerAction"></DatePicker>
<Text fx:id="actiontarget" GridPane.columnIndex="0" GridPane.rowIndex="1" />
</GridPane>
控制器看起来像:
public class DatePickerController
{
@FXML
private Text actiontarget;
@FXML
private DatePicker datepicker;
@FXML
protected void handleDatePickerAction(ActionEvent event)
{
actiontarget.setText(datepicker.getValue().toString());
}
}
于 2015-10-14T20:10:15.013 回答