下面列出了怎么用javafx.scene.control.SpinnerValueFactory的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
rootPane.setVisible(false);
/*
Initializes the controller class.
*/ /**
* Initializes the controller class.
*/
SpinnerValueFactory<Integer> valueFactoryFrom = new SpinnerValueFactory.IntegerSpinnerValueFactory(1, 100, 1);
SpinnerValueFactory<Integer> valueFactoryUntil = new SpinnerValueFactory.IntegerSpinnerValueFactory(1, 100, 1);
fromLevel.setValueFactory(valueFactoryFrom);
fromLevel.setStyle(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL);
untilLevel.setValueFactory(valueFactoryUntil);
untilLevel.setStyle(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL);
fromLevel.setEditable(true);
untilLevel.setEditable(true);
Util.addIntegerLimiterToIntegerSpinner(fromLevel, valueFactoryFrom);
Util.addIntegerLimiterToIntegerSpinner(untilLevel, valueFactoryUntil);
valueFactoryFrom.valueProperty().addListener((arg0, arg1, arg2) -> groupSliderChange(fromLevel.getValue(),0));
valueFactoryUntil.valueProperty().addListener((arg0, arg1, arg2) -> groupSliderChange(untilLevel.getValue(),1));
}
/**
* {@inheritDoc}
*/
@Override
public void initializeParts() {
super.initializeParts();
getStyleClass().addAll("simple-integer-control");
final SpinnerValueFactory.IntegerSpinnerValueFactory factory =
new SpinnerValueFactory.IntegerSpinnerValueFactory(
Integer.MIN_VALUE, Integer.MAX_VALUE, field.getValue()
);
// override old converter (IntegerStringConverter) because it throws
// NumberFormatException if value can not be parsed to Integer
factory.setConverter(new NoExceptionStringConverter());
editableSpinner.setValueFactory(factory);
editableSpinner.focusedProperty().addListener((observable, wasFocused, isFocused) -> {
if (wasFocused && !isFocused) {
overrideNonIntegerSpinnerValues();
}
});
editableSpinner.addEventHandler(KeyEvent.ANY, event -> {
if (event.getCode() == KeyCode.ENTER) {
overrideNonIntegerSpinnerValues();
}
});
}
public void initialize(DesignerApplication app) throws Exception {
setApp(app);
// button images
setButtonImages();
// set up resolver item display
intializeItemTable();
// value and state charts
initializeCharts();
// spinner value factory for update period
SpinnerValueFactory<Integer> periodValueFactory = new SpinnerValueFactory.IntegerSpinnerValueFactory(1,
Integer.MAX_VALUE, DEFAULT_UPDATE_SEC);
spUpdatePeriod.setValueFactory(periodValueFactory);
}
@SuppressWarnings("unchecked")
@Override
public boolean marathon_select(String value) {
Spinner<?> spinner = (Spinner<?>) getComponent();
if (!spinner.isEditable()) {
@SuppressWarnings("rawtypes")
SpinnerValueFactory factory = ((Spinner<?>) getComponent()).getValueFactory();
Object convertedValue = factory.getConverter().fromString(value);
factory.setValue(convertedValue);
return true;
}
TextField spinnerEditor = spinner.getEditor();
if (spinnerEditor == null) {
throw new JavaAgentException("Null value returned by getEditor() on spinner", null);
}
IJavaFXElement ele = JavaFXElementFactory.createElement(spinnerEditor, driver, window);
spinnerEditor.getProperties().put("marathon.celleditor", true);
ele.marathon_select(value);
return true;
}
private Spinner<Object> createListSpinner() {
Spinner<Object> spinner = new Spinner<>();
spinner.setId("list-spinner");
List<Object> names = new ArrayList<Object>();
names.add("January");
names.add("February");
names.add("March");
names.add("April");
names.add("May");
names.add("June");
names.add("July");
names.add("August");
names.add("September");
names.add("October");
names.add("November");
names.add("December");
spinner.setValueFactory(new SpinnerValueFactory.ListSpinnerValueFactory<Object>(FXCollections.observableArrayList(names)));
return spinner;
}
private void commitEditorText(Spinner<T> spinner) {
if (!spinner.isEditable()) {
return;
}
String text = spinner.getEditor().getText();
SpinnerValueFactory<T> valueFactory = spinner.getValueFactory();
if (valueFactory != null) {
StringConverter<T> converter = valueFactory.getConverter();
if (converter != null) {
try {
T value = converter.fromString(text);
setValue(valueFactory, value);
} catch (Exception e) {
spinner.getEditor().setText(valueFactory.getValue().toString());
}
}
}
}
@FXML
void initialize()
{
var potionValueFactory =
new SpinnerValueFactory.IntegerSpinnerValueFactory(model.getMaxPotionLevelBounds().min,
model.getMaxWandLevelBounds().max,
SettingsHandler.maxPotionSpellLevel().getValue(), 1
);
potionSpinner.setValueFactory(potionValueFactory);
var wandValueFactory =
new SpinnerValueFactory.IntegerSpinnerValueFactory(model.getMaxWandLevelBounds().min,
model.getMaxWandLevelBounds().max,
SettingsHandler.maxWandSpellLevel().getValue(), 1
);
wandSpinner.setValueFactory(wandValueFactory);
// TODO: consider adding an apply button that sets values rather than using binding directly
model.maxPotionLevelProperty().bind(potionSpinner.valueProperty());
model.maxWandLevelProperty().bind(wandSpinner.valueProperty());
}
@FXML
void initialize()
{
var potionValueFactory =
new SpinnerValueFactory.IntegerSpinnerValueFactory(model.getMaxPotionLevelBounds().min,
model.getMaxWandLevelBounds().max,
SettingsHandler.maxPotionSpellLevel().getValue(), 1
);
potionSpinner.setValueFactory(potionValueFactory);
var wandValueFactory =
new SpinnerValueFactory.IntegerSpinnerValueFactory(model.getMaxWandLevelBounds().min,
model.getMaxWandLevelBounds().max,
SettingsHandler.maxWandSpellLevel().getValue(), 1
);
wandSpinner.setValueFactory(wandValueFactory);
// TODO: consider adding an apply button that sets values rather than using binding directly
model.maxPotionLevelProperty().bind(potionSpinner.valueProperty());
model.maxWandLevelProperty().bind(wandSpinner.valueProperty());
}
/**
* {@inheritDoc}
*/
@Override
public void initializeParts() {
super.initializeParts();
getStyleClass().add("simple-double-control");
editableSpinner.setValueFactory(new SpinnerValueFactory.DoubleSpinnerValueFactory(
-Double.MAX_VALUE, Double.MAX_VALUE, field.getValue()
));
}
public static void configureSpinner(Spinner<Integer> spinner, IntegerProperty referenceProperty, int minValue, int maxValue) {
spinner.setEditable(true);
spinner.setTooltip(TooltipCreator.createFrom("Max value: " + maxValue));
spinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(minValue,
Integer.MAX_VALUE,
referenceProperty.get()));
GuiUtils.configureTextFieldToAcceptOnlyValidData(spinner.getEditor(),
stringConsumer(referenceProperty),
validationFunc(maxValue));
configureTextFieldToAcceptOnlyDecimalValues(spinner.getEditor());
}
private Spinner<Double> createDoubleSpinner() {
Spinner<Double> spinner = new Spinner<Double>();
spinner.setId("double-spinner");
spinner.setValueFactory(new SpinnerValueFactory.DoubleSpinnerValueFactory(25.50, 50.50));
spinner.setEditable(true);
return spinner;
}
@Override
public void start(final Stage stage)
{
final Label label = new Label("Demo:");
SpinnerValueFactory<Double> svf = new SpinnerValueFactory.DoubleSpinnerValueFactory(0, 1000);
Spinner<Double> spinner = new Spinner<>();
spinner.setValueFactory(svf);
spinner.editorProperty().getValue().setStyle("-fx-text-fill:" + "black");
spinner.editorProperty().getValue().setBackground(
new Background(new BackgroundFill(Color.AZURE, CornerRadii.EMPTY, Insets.EMPTY)));
//spinner.getStyleClass().add(Spinner.STYLE_CLASS_ARROWS_ON_LEFT_VERTICAL);
//int x = spinner.getStyleClass().indexOf(Spinner.STYLE_CLASS_ARROWS_ON_LEFT_VERTICAL);
//if (x > 0) spinner.getStyleClass().remove(x);
spinner.setEditable(true);
spinner.setPrefWidth(80);
spinner.valueProperty().addListener((prop, old, value) ->
{
System.out.println("Value: " + value);
});
final HBox root = new HBox(label, spinner);
final Scene scene = new Scene(root, 800, 700);
stage.setScene(scene);
stage.setTitle("Spinner Demo");
stage.show();
}
private void setValue(SpinnerValueFactory<T> valueFactory, T value) {
if (valueFactory instanceof SpinnerValueFactory.IntegerSpinnerValueFactory) {
setValue((SpinnerValueFactory.IntegerSpinnerValueFactory) valueFactory, (Integer) value);
} else if (valueFactory instanceof SpinnerValueFactory.DoubleSpinnerValueFactory) {
setValue((SpinnerValueFactory.DoubleSpinnerValueFactory) valueFactory, (Double) value);
}
valueFactory.setValue(value);
}
public JFXSpinner(JFXContainer<? extends Region> parent) {
super(new Spinner<Integer>(), parent);
this.selectionListener = new JFXSelectionListenerChangeManager<Number>(this);
this.valueFactory = new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 100, 0);
this.getControl().setValueFactory(this.valueFactory);
}
private void commitEditorText() {
if (!isEditable())
return;
String text = getEditor().getText();
SpinnerValueFactory<T> valueFactory = getValueFactory();
if (valueFactory != null) {
StringConverter<T> converter = valueFactory.getConverter();
if (converter != null) {
T value = converter.fromString(text);
valueFactory.setValue(value);
}
}
}
@SuppressWarnings("unchecked")
GeneralOptionsPane() {
initComponents();
Font titleFont = Font.font(16);
editorSettingsLabel.setFont(titleFont);
fileSettingsLabel.setFont(titleFont);
// font family
fontFamilyField.getItems().addAll(getMonospacedFonts());
fontFamilyField.getSelectionModel().select(0);
fontFamilyField.setButtonCell(new FontListCell());
fontFamilyField.setCellFactory(p -> new FontListCell());
// font size
fontSizeField.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(Options.MIN_FONT_SIZE, Options.MAX_FONT_SIZE));
// line separator
String defaultLineSeparator = System.getProperty( "line.separator", "\n" );
String defaultLineSeparatorStr = defaultLineSeparator.replace("\r", "CR").replace("\n", "LF");
lineSeparatorField.getItems().addAll(
new Item<>(Messages.get("GeneralOptionsPane.platformDefault", defaultLineSeparatorStr), null),
new Item<>(Messages.get("GeneralOptionsPane.sepWindows"), "\r\n"),
new Item<>(Messages.get("GeneralOptionsPane.sepUnix"), "\n"));
// encoding
encodingField.getItems().addAll(getAvailableEncodings());
// file extensions
markdownFileExtensionsField.setPromptText(Options.DEF_MARKDOWN_FILE_EXTENSIONS);
}
EditorOptionsPane() {
initComponents();
Font titleFont = Font.font(16);
markersTitle.setFont(titleFont);
formatTitle.setFont(titleFont);
strongEmphasisMarkerField.getItems().addAll("**", "__");
emphasisMarkerField.getItems().addAll("*", "_");
bulletListMarkerField.getItems().addAll("-", "+", "*");
wrapLineLengthField.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(Options.MIN_WRAP_LINE_LENGTH, Integer.MAX_VALUE));
formatOnlyModifiedParagraphsCheckBox.disableProperty().bind(formatOnSaveCheckBox.selectedProperty().not());
}
/**
* Spinnerの変更を即座に反映する
*
* @param spinner Spinner
*/
private <T> void spinnerHandller(Spinner<T> spinner) {
spinner.getEditor().textProperty().addListener((ob, o, n) -> {
SpinnerValueFactory<T> f = spinner.getValueFactory();
T value = f.getConverter().fromString("".equals(n) ? "0" : n);
if (!value.equals(f.getValue())) {
f.setValue(value);
}
});
}
private HBox createTimeSpinners() {
datePicker = new DatePicker();
datePicker.setConverter(new LocalDateStringConverter(
TemporalFormatting.DATE_FORMATTER, TemporalFormatting.DATE_FORMATTER));
datePicker.getEditor().textProperty().addListener((v, o, n) -> {
update();
updateTimeZoneList();
});
datePicker.setValue(LocalDate.now());
datePicker.valueProperty().addListener((v, o, n) -> {
update();
updateTimeZoneList();
});
hourSpinner = new Spinner<>(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 23));
minSpinner = new Spinner<>(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 59));
secSpinner = new Spinner<>(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 59));
milliSpinner = new Spinner<>(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 999));
hourSpinner.getValueFactory().setValue(LocalTime.now(ZoneOffset.UTC).getHour());
minSpinner.getValueFactory().setValue(LocalTime.now(ZoneOffset.UTC).getMinute());
secSpinner.getValueFactory().setValue(LocalTime.now(ZoneOffset.UTC).getSecond());
milliSpinner.getValueFactory().setValue(0);
final HBox timeSpinnerContainer = new HBox(CONTROLS_DEFAULT_VERTICAL_SPACING);
final Label dateLabel = new Label("Date:");
dateLabel.setId(LABEL_ID);
dateLabel.setLabelFor(datePicker);
final Label hourSpinnerLabel = new Label("Hour:");
hourSpinnerLabel.setId(LABEL_ID);
hourSpinnerLabel.setLabelFor(hourSpinner);
final Label minSpinnerLabel = new Label("Minute:");
minSpinnerLabel.setId(LABEL_ID);
minSpinnerLabel.setLabelFor(minSpinner);
final Label secSpinnerLabel = new Label("Second:");
secSpinnerLabel.setId(LABEL_ID);
secSpinnerLabel.setLabelFor(secSpinner);
final Label milliSpinnerLabel = new Label("Millis:");
milliSpinnerLabel.setId(LABEL_ID);
milliSpinnerLabel.setLabelFor(milliSpinner);
hourSpinner.setPrefWidth(NUMBER_SPINNER_WIDTH);
minSpinner.setPrefWidth(NUMBER_SPINNER_WIDTH);
secSpinner.setPrefWidth(NUMBER_SPINNER_WIDTH);
milliSpinner.setPrefWidth(MILLIS_SPINNER_WIDTH);
hourSpinner.setEditable(true);
minSpinner.setEditable(true);
secSpinner.setEditable(true);
milliSpinner.setEditable(true);
hourSpinner.valueProperty().addListener((o, n, v) -> {
update();
updateTimeZoneList();
});
minSpinner.valueProperty().addListener((o, n, v) -> {
update();
updateTimeZoneList();
});
secSpinner.valueProperty().addListener((o, n, v) -> {
update();
updateTimeZoneList();
});
milliSpinner.valueProperty().addListener((o, n, v) -> {
update();
updateTimeZoneList();
});
final VBox dateLabelNode = new VBox(5);
dateLabelNode.getChildren().addAll(dateLabel, datePicker);
final VBox hourLabelNode = new VBox(5);
hourLabelNode.getChildren().addAll(hourSpinnerLabel, hourSpinner);
final VBox minLabelNode = new VBox(5);
minLabelNode.getChildren().addAll(minSpinnerLabel, minSpinner);
final VBox secLabelNode = new VBox(5);
secLabelNode.getChildren().addAll(secSpinnerLabel, secSpinner);
final VBox milliLabelNode = new VBox(5);
milliLabelNode.getChildren().addAll(milliSpinnerLabel, milliSpinner);
timeSpinnerContainer.getChildren().addAll(dateLabelNode, hourLabelNode, minLabelNode, secLabelNode, milliLabelNode);
return timeSpinnerContainer;
}
private HBox createTimeSpinners() {
datePicker = new DatePicker();
datePicker.setConverter(new LocalDateStringConverter(
TemporalFormatting.DATE_FORMATTER, TemporalFormatting.DATE_FORMATTER));
datePicker.getEditor().textProperty().addListener((v, o, n) -> {
update();
});
datePicker.setValue(LocalDate.now());
datePicker.valueProperty().addListener((v, o, n) -> {
update();
});
hourSpinner = new Spinner<>(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 23));
minSpinner = new Spinner<>(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 59));
secSpinner = new Spinner<>(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 59));
milliSpinner = new Spinner<>(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 999));
hourSpinner.getValueFactory().setValue(LocalTime.now(ZoneOffset.UTC).getHour());
minSpinner.getValueFactory().setValue(LocalTime.now(ZoneOffset.UTC).getMinute());
secSpinner.getValueFactory().setValue(LocalTime.now(ZoneOffset.UTC).getSecond());
milliSpinner.getValueFactory().setValue(0);
final HBox timeSpinnerContainer = new HBox(CONTROLS_DEFAULT_VERTICAL_SPACING);
final Label dateLabel = new Label("Date:");
dateLabel.setId(LABEL_ID);
dateLabel.setLabelFor(datePicker);
final Label hourSpinnerLabel = new Label("Hour:");
hourSpinnerLabel.setId(LABEL_ID);
hourSpinnerLabel.setLabelFor(hourSpinner);
final Label minSpinnerLabel = new Label("Minute:");
minSpinnerLabel.setId(LABEL_ID);
minSpinnerLabel.setLabelFor(minSpinner);
final Label secSpinnerLabel = new Label("Second:");
secSpinnerLabel.setId(LABEL_ID);
secSpinnerLabel.setLabelFor(secSpinner);
final Label milliSpinnerLabel = new Label("Millis:");
milliSpinnerLabel.setId(LABEL_ID);
milliSpinnerLabel.setLabelFor(milliSpinner);
hourSpinner.setPrefWidth(NUMBER_SPINNER_WIDTH);
minSpinner.setPrefWidth(NUMBER_SPINNER_WIDTH);
secSpinner.setPrefWidth(NUMBER_SPINNER_WIDTH);
milliSpinner.setPrefWidth(MILLIS_SPINNER_WIDTH);
hourSpinner.setEditable(true);
minSpinner.setEditable(true);
secSpinner.setEditable(true);
milliSpinner.setEditable(true);
hourSpinner.valueProperty().addListener((o, n, v) -> {
update();
});
minSpinner.valueProperty().addListener((o, n, v) -> {
update();
});
secSpinner.valueProperty().addListener((o, n, v) -> {
update();
});
milliSpinner.valueProperty().addListener((o, n, v) -> {
update();
});
final VBox dateLabelNode = new VBox(5);
dateLabelNode.getChildren().addAll(dateLabel, datePicker);
final VBox hourLabelNode = new VBox(5);
hourLabelNode.getChildren().addAll(hourSpinnerLabel, hourSpinner);
final VBox minLabelNode = new VBox(5);
minLabelNode.getChildren().addAll(minSpinnerLabel, minSpinner);
final VBox secLabelNode = new VBox(5);
secLabelNode.getChildren().addAll(secSpinnerLabel, secSpinner);
final VBox milliLabelNode = new VBox(5);
milliLabelNode.getChildren().addAll(milliSpinnerLabel, milliSpinner);
timeSpinnerContainer.getChildren().addAll(dateLabelNode, hourLabelNode, minLabelNode, secLabelNode, milliLabelNode);
return timeSpinnerContainer;
}
private HBox createTimeSpinners() {
hourSpinner = new Spinner<>(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 23));
minSpinner = new Spinner<>(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 59));
secSpinner = new Spinner<>(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 59));
milliSpinner = new Spinner<>(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 999));
hourSpinner.getValueFactory().setValue(LocalTime.now(ZoneOffset.UTC).getHour());
minSpinner.getValueFactory().setValue(LocalTime.now(ZoneOffset.UTC).getMinute());
secSpinner.getValueFactory().setValue(LocalTime.now(ZoneOffset.UTC).getSecond());
milliSpinner.getValueFactory().setValue(0);
final HBox timeSpinnerContainer = new HBox(CONTROLS_DEFAULT_VERTICAL_SPACING);
final Label hourSpinnerLabel = new Label("hr:");
hourSpinnerLabel.setId(LABEL);
hourSpinnerLabel.setLabelFor(hourSpinner);
final Label minSpinnerLabel = new Label("min:");
minSpinnerLabel.setId(LABEL);
minSpinnerLabel.setLabelFor(minSpinner);
final Label secSpinnerLabel = new Label("sec:");
secSpinnerLabel.setId(LABEL);
secSpinnerLabel.setLabelFor(secSpinner);
final Label milliSpinnerLabel = new Label("ms:");
milliSpinnerLabel.setId(LABEL);
milliSpinnerLabel.setLabelFor(milliSpinner);
hourSpinner.setPrefWidth(NUMBER_SPINNER_WIDTH);
minSpinner.setPrefWidth(NUMBER_SPINNER_WIDTH);
secSpinner.setPrefWidth(NUMBER_SPINNER_WIDTH);
milliSpinner.setPrefWidth(MILLIS_SPINNER_WIDTH);
hourSpinner.setEditable(true);
minSpinner.setEditable(true);
secSpinner.setEditable(true);
milliSpinner.setEditable(true);
hourSpinner.valueProperty().addListener((o, n, v) -> {
update();
});
minSpinner.valueProperty().addListener((o, n, v) -> {
update();
});
secSpinner.valueProperty().addListener((o, n, v) -> {
update();
});
milliSpinner.valueProperty().addListener((o, n, v) -> {
update();
});
final VBox hourLabelNode = new VBox(5);
hourLabelNode.getChildren().addAll(hourSpinnerLabel, hourSpinner);
final VBox minLabelNode = new VBox(5);
minLabelNode.getChildren().addAll(minSpinnerLabel, minSpinner);
final VBox secLabelNode = new VBox(5);
secLabelNode.getChildren().addAll(secSpinnerLabel, secSpinner);
final VBox milliLabelNode = new VBox(5);
milliLabelNode.getChildren().addAll(milliSpinnerLabel, milliSpinner);
timeSpinnerContainer.getChildren().addAll(hourLabelNode, minLabelNode, secLabelNode, milliLabelNode);
return timeSpinnerContainer;
}
@Override
public void initialize(URL location, ResourceBundle resources) {
SpinnerValueFactory valueFactory = new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 100);
spinner.setValueFactory(valueFactory);
}
private Spinner<Integer> createIntegerSpinner() {
Spinner<Integer> spinner = new Spinner<>();
spinner.setId("integer-spinner");
spinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 50));
return spinner;
}
private SpinnerValueFactory<String> createSVF()
{
SpinnerValueFactory<String> svf = new TextSpinnerValueFactory();
svf.setValue(value_text);
return svf;
}
public WraparoundValueFactory(final int min, final int max, final SpinnerValueFactory<Integer> next)
{
this.min = min;
this.max = max;
this.next = next;
}
private void setValue(SpinnerValueFactory.IntegerSpinnerValueFactory valueFactory, Integer value) {
valueFactory.setValue(Math.min(Math.max(value, valueFactory.getMin()), valueFactory.getMax()));
}
private void setValue(SpinnerValueFactory.DoubleSpinnerValueFactory valueFactory, Double value) {
valueFactory.setValue(Math.min(Math.max(value, valueFactory.getMin()), valueFactory.getMax()));
}
SpinnerCell(int min, int max, int initial, int step) {
spinner = new NumericSpinner<>();
spinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(min, max, initial, step));
setEditable(true);
}
public SpinnerAutoCommit(SpinnerValueFactory<T> valueFactory) {
super(valueFactory);
addListenerKeyChange();
}
@FXML
void initialize() {
// SplitPaneの分割サイズ
Timeline x = new Timeline();
x.getKeyFrames().add(new KeyFrame(Duration.millis(1), (e) -> {
Tools.Conrtols.setSplitWidth(this.splitPane, this.getClass() + "#" + "splitPane");
}));
x.play();
// Spinnerに最小値最大値現在値を設定
this.nowLv.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(1, ExpTable.maxLv(), 1, 1));
this.goalLv.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(1, ExpTable.maxLv(), 1, 1));
// コンボボックス
this.shipList.setItems(this.ships);
this.shipList();
// 海域
this.seaAreaList();
// 評価
this.rank.setItems(FXCollections.observableArrayList(Rank.values()));
this.rank.getSelectionModel().select(AppConfig.get().getResultRank());
// カラムとオブジェクトのバインド
this.id.setCellValueFactory(new PropertyValueFactory<>("id"));
this.ship.setCellValueFactory(new PropertyValueFactory<>("ship"));
this.ship.setCellFactory(p -> new ShipImageTableCell());
this.lv.setCellValueFactory(new PropertyValueFactory<>("lv"));
this.afterLv.setCellValueFactory(new PropertyValueFactory<>("afterLv"));
// 改装レベル不足の艦娘
this.shortageShip.setItems(this.item);
this.shortageShip();
// イベントリスナー
this.shipList.getSelectionModel()
.selectedItemProperty()
.addListener((ChangeListener<ShipWrapper>) this::changeShip);
this.nowLv.getValueFactory()
.valueProperty()
.addListener((ChangeListener<Integer>) this::changeNowLv);
this.goalLv.getValueFactory()
.valueProperty()
.addListener((ChangeListener<Integer>) this::changeGoalLv);
this.sea.getSelectionModel()
.selectedItemProperty()
.addListener((ChangeListener<AppSeaAreaExp>) (ov, o, n) -> this.changeSeaArea());
this.rank.getSelectionModel()
.selectedItemProperty()
.addListener((ChangeListener<Rank>) (ov, o, n) -> this.update());
this.shortageShip.getSelectionModel()
.selectedItemProperty()
.addListener((ChangeListener<ShortageShipItem>) this::changeShip);
// 旗艦ID
Integer flagShipId = DeckPortCollection.get()
.getDeckPortMap()
.get(1)
.getShip()
.get(0);
// 旗艦
ShipWrapper flagShip = this.ships.stream()
.filter(w -> w.getShip().getId().equals(flagShipId))
.findAny()
.get();
// 発火させるためにここでselect
this.sea.getSelectionModel().select(AppConfig.get().getSeaAreaIndex());
this.shipList.getSelectionModel().select(flagShip);
}