类javafx.scene.control.cell.TextFieldListCell源码实例Demo

下面列出了怎么用javafx.scene.control.cell.TextFieldListCell的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: OpenLabeler   文件: NameListPane.java
public NameListPane() {
    FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/preference/NameListPane.fxml"), bundle);
    loader.setRoot(this);
    loader.setController(this);

    try {
        loader.load();
    }
    catch (Exception ex) {
        LOG.log(Level.SEVERE, "Unable to load FXML", ex);
    }

    listName.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    listName.setCellFactory(TextFieldListCell.forListView());
    listName.setOnEditCommit((EventHandler<ListView.EditEvent<String>>) t -> {
        listName.getItems().set(t.getIndex(), t.getNewValue());
        listName.getSelectionModel().clearAndSelect(t.getIndex());
    });
}
 
@Test
public void select() {
    @SuppressWarnings("unchecked")
    ListView<String> listView = (ListView<String>) getPrimaryStage().getScene().getRoot().lookup(".list-view");
    LoggingRecorder lr = new LoggingRecorder();
    Platform.runLater(() -> {
        @SuppressWarnings("unchecked")
        TextFieldListCell<String> cell = (TextFieldListCell<String>) getCellAt(listView, 3);
        Point2D point = getPoint(listView, 3);
        RFXListView rfxListView = new RFXListView(listView, null, point, lr);
        rfxListView.focusGained(rfxListView);
        cell.startEdit();
        cell.updateItem("Item 4 Modified", false);
        cell.commitEdit("Item 4 Modified");
        rfxListView.focusLost(rfxListView);
    });
    List<Recording> recordings = lr.waitAndGetRecordings(1);
    Recording recording = recordings.get(0);
    AssertJUnit.assertEquals("recordSelect", recording.getCall());
    AssertJUnit.assertEquals("Item 4 Modified", recording.getParameters()[0]);
}
 
源代码3 项目: beatoraja   文件: FolderEditorView.java
public void initialize(URL arg0, ResourceBundle arg1) {		
	folders.getSelectionModel().selectedIndexProperty().addListener((observable, oldVal, newVal) -> {
		if(oldVal != newVal) {
			updateTableFolder();				
		}
	});
	folders.setCellFactory((ListView) -> {
		return new TextFieldListCell<TableFolder>() {
			@Override
			public void updateItem(TableFolder course, boolean empty) {
				super.updateItem(course, empty);
				setText(empty ? "" : course.getName());
			}
		};
	});
	folderSongsController.setVisible("fullTitle", "sha256");
	searchSongsController.setVisible("fullTitle", "fullArtist", "mode", "level", "notes", "sha256");

	searchSongs.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
	
	updateFolder(null);
}
 
源代码4 项目: standalone-app   文件: PathEditorController.java
@FXML
private void initialize() {
    this.list.setCellFactory(TextFieldListCell.forListView());

    List<String> path = configuration.getList(String.class, Settings.PATH_KEY, Collections.emptyList());
    this.list.getItems().addAll(path);

    stage = new Stage();
    stage.setOnCloseRequest(event -> {
        event.consume();
        stage.hide();
        this.list.getItems().removeAll(Arrays.asList(null, ""));
        configuration.setProperty(Settings.PATH_KEY, this.list.getItems());
        eventBus.post(new PathUpdatedEvent());
        pathController.reload();
    });
    stage.setScene(new Scene(root));
    stage.getIcons().add(new Image(getClass().getResourceAsStream("/res/icon.png")));
    stage.setTitle("Edit Path");
}
 
源代码5 项目: metastone   文件: BattleOfDecksConfigView.java
public BattleOfDecksConfigView() {
	FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/BattleOfDecksConfigView.fxml"));
	fxmlLoader.setRoot(this);
	fxmlLoader.setController(this);

	try {
		fxmlLoader.load();
	} catch (IOException exception) {
		throw new RuntimeException(exception);
	}

	setupBehaviourBox();
	setupNumberOfGamesBox();

	selectedDecksListView.setCellFactory(TextFieldListCell.forListView(new DeckStringConverter()));
	selectedDecksListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
	availableDecksListView.setCellFactory(TextFieldListCell.forListView(new DeckStringConverter()));
	availableDecksListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

	addButton.setOnAction(this::handleAddButton);
	removeButton.setOnAction(this::handleRemoveButton);

	backButton.setOnAction(event -> NotificationProxy.sendNotification(GameNotification.MAIN_MENU));
	startButton.setOnAction(this::handleStartButton);
}
 
源代码6 项目: metastone   文件: CardCollectionEditor.java
public CardCollectionEditor(String title, CardCollection cardCollection, ICardCollectionEditingListener listener, int cardLimit) {
	super("CardCollectionEditor.fxml");
	this.listener = listener;
	this.cardLimit = cardLimit;

	setTitle(title);

	editableListView.setCellFactory(TextFieldListCell.forListView(new CardStringConverter()));
	populateEditableView(cardCollection);

	catalogueListView.setCellFactory(TextFieldListCell.forListView(new CardStringConverter()));
	populateCatalogueView(null);

	filterTextfield.textProperty().addListener(this::onFilterTextChanged);
	clearFilterButton.setOnAction(actionEvent -> filterTextfield.clear());

	okButton.setOnAction(this::handleOkButton);
	cancelButton.setOnAction(this::handleCancelButton);

	addCardButton.setOnAction(this::handleAddCardButton);
	removeCardButton.setOnAction(this::handleRemoveCardButton);
}
 
源代码7 项目: metastone   文件: TrainingConfigView.java
public TrainingConfigView() {
	FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/TrainingConfigView.fxml"));
	fxmlLoader.setRoot(this);
	fxmlLoader.setController(this);

	try {
		fxmlLoader.load();
	} catch (IOException exception) {
		throw new RuntimeException(exception);
	}

	setupDeckBox();
	setupNumberOfGamesBox();

	selectedDecksListView.setCellFactory(TextFieldListCell.forListView(new DeckStringConverter()));
	selectedDecksListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
	availableDecksListView.setCellFactory(TextFieldListCell.forListView(new DeckStringConverter()));
	availableDecksListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

	addButton.setOnAction(this::handleAddButton);
	removeButton.setOnAction(this::handleRemoveButton);

	backButton.setOnAction(event -> NotificationProxy.sendNotification(GameNotification.MAIN_MENU));
	startButton.setOnAction(this::handleStartButton);
}
 
源代码8 项目: marathonv5   文件: TextFieldListViewSample.java
public TextFieldListViewSample() {
    final ListView<String> listView = new ListView<String>();
    listView.setItems(FXCollections.observableArrayList("Row 1", "Row 2", "Long Row 3", "Row 4", "Row 5", "Row 6", "Row 7",
            "Row 8", "Row 9", "Row 10", "Row 11", "Row 12", "Row 13", "Row 14", "Row 15", "Row 16", "Row 17", "Row 18",
            "Row 19", "Row 20"));
    listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    listView.setEditable(true);
    listView.setCellFactory(TextFieldListCell.forListView());
    getChildren().add(listView);
}
 
源代码9 项目: marathonv5   文件: RFXTextFieldListCell.java
@SuppressWarnings("unchecked")
@Override
public String _getValue() {
    TextFieldListCell<?> cell = (TextFieldListCell<?>) node;
    @SuppressWarnings("rawtypes")
    StringConverter converter = cell.getConverter();
    if (converter != null) {
        return converter.toString(cell.getItem());
    }
    return cell.getItem().toString();
}
 
源代码10 项目: beatoraja   文件: CourseEditorView.java
public void initialize(URL arg0, ResourceBundle arg1) {
	gradeType.getItems().setAll(null, CLASS, MIRROR, RANDOM);
	hispeedType.getItems().setAll(null, NO_SPEED);
	judgeType.getItems().setAll(null, NO_GOOD, NO_GREAT);
	gaugeType.getItems().setAll(null, GAUGE_LR2,  GAUGE_5KEYS,  GAUGE_7KEYS,  GAUGE_9KEYS,  GAUGE_24KEYS);
	lnType.getItems().setAll(null, LN,  CN,  HCN);
	
	courses.getSelectionModel().selectedIndexProperty().addListener((observable, oldVal, newVal) -> {
		if(oldVal != newVal) {
			updateCourseData();				
		}
	});
	courses.setCellFactory((ListView) -> {
		return new TextFieldListCell<CourseData>() {
			@Override
			public void updateItem(CourseData course, boolean empty) {
				super.updateItem(course, empty);
				setText(empty ? "" : course.getName());
			}
		};
	});
	courseSongsController.setVisible("fullTitle", "sha256");
	searchSongsController.setVisible("fullTitle", "fullArtist", "mode", "level", "notes", "sha256");

	searchSongs.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

	updateCourse(null);
}
 
源代码11 项目: old-mzmine3   文件: FeatureTableColumnsEditor.java
public FeatureTableColumnsEditor(PropertySheet.Item parameter) {

    // HBox properties
    setSpacing(10);
    setAlignment(Pos.CENTER_LEFT);

    namePatternList = new ListView<>();
    namePatternList.setEditable(true);
    namePatternList.setPrefHeight(150);
    namePatternList.setCellFactory(TextFieldListCell.forListView());

    Button addButton = new Button("Add");
    addButton.setOnAction(e -> {
      TextInputDialog dialog = new TextInputDialog();
      dialog.setTitle("Add name pattern");
      dialog.setHeaderText("New name pattern");
      Optional<String> result = dialog.showAndWait();
      result.ifPresent(value -> namePatternList.getItems().add(value));
    });

    Button removeButton = new Button("Remove");
    removeButton.setOnAction(e -> {
      List<String> selectedItems = namePatternList.getSelectionModel().getSelectedItems();
      namePatternList.getItems().removeAll(selectedItems);
    });

    VBox buttons = new VBox(addButton, removeButton);
    buttons.setSpacing(10);

    getChildren().addAll(namePatternList, buttons);
  }
 
@Override
public FXFormNode call(Void param) {

    final ListView<Path> listView = spellcheckConfigBean.getLanguagePathList();

    listView.setCellFactory(li -> new TextFieldListCell<>(new StringConverter<Path>() {
        @Override
        public String toString(Path object) {
            return IOHelper.getPathCleanName(object);
        }

        @Override
        public Path fromString(String string) {
            return IOHelper.getPath(string);
        }
    }));

    HBox hBox = new HBox(5);
    hBox.getChildren().add(listView);

    hBox.getChildren().add(new VBox(10, languageLabel, setDefaultButton, addNewLanguageButton));
    HBox.setHgrow(listView, Priority.ALWAYS);

    listView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);

    setDefaultButton.setOnAction(this::setDefaultLanguage);

    return new FXFormNodeWrapper(hBox, listView.itemsProperty());
}
 
源代码13 项目: tcMenu   文件: UIEnumMenuItem.java
@Override
protected int internalInitPanel(GridPane grid, int idx) {
    idx++;
    grid.add(new Label("Values"), 0, idx);
    ObservableList<String> list = FXCollections.observableArrayList(getMenuItem().getEnumEntries());
    listView = new ListView<>(list);
    listView.setEditable(true);

    listView.setCellFactory(TextFieldListCell.forListView());

    listView.setOnEditCommit(t -> {
        listView.getItems().set(t.getIndex(), t.getNewValue());
    });

    listView.setMinHeight(100);
    grid.add(listView, 1, idx, 1, 3);
    idx+=3;
    Button addButton = new Button("Add");
    addButton.setId("addEnumEntry");
    Button removeButton = new Button("Remove");
    removeButton.setId("removeEnumEntry");
    removeButton.setDisable(true);
    HBox hbox = new HBox(addButton, removeButton);
    grid.add(hbox, 1, idx);

    addButton.setOnAction(event -> {
        listView.getItems().add("ChangeMe");
        listView.getSelectionModel().selectLast();
    });

    removeButton.setOnAction(event -> {
        String selectedItem = listView.getSelectionModel().getSelectedItem();
        if(selectedItem != null) {
            list.remove(selectedItem);
        }
    });

    list.addListener((ListChangeListener<? super String>) observable -> callChangeConsumer());

    listView.setId("enumList");
    listView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) ->
            removeButton.setDisable(newValue == null)
    );
    listView.getSelectionModel().selectFirst();
    return idx;
}
 
源代码14 项目: BlockMap   文件: AutoCompletePopupSkin2.java
/**
 * @param displayConverter
 *            An alternate {@link StringConverter} to use. This way, you can show autocomplete suggestions that when applied will fill in a
 *            different text than displayed. For example, you may preview {@code Files.newBufferedReader(Path: path) - Bufferedreader} but
 *            only fill in {@code Files.newBufferedReader(}
 */
public AutoCompletePopupSkin2(AutoCompletePopup<T> control, StringConverter<T> displayConverter) {
	this(control, TextFieldListCell.forListView(displayConverter));
}
 
 类所在包
 类方法
 同包方法