本文整理汇总了Java中javafx.scene.control.ListView.setCellFactory方法的典型用法代码示例。如果您正苦于以下问题:Java ListView.setCellFactory方法的具体用法?Java ListView.setCellFactory怎么用?Java ListView.setCellFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.ListView
的用法示例。
在下文中一共展示了ListView.setCellFactory方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ComponentSelectorPane
import javafx.scene.control.ListView; //导入方法依赖的package包/类
public ComponentSelectorPane(String listTitle, ObservableList<Class<? extends Component>> displayedData, SpriteDataPane infoPane) {
this.infoPane=infoPane;
this.setPrefWidth(PREF_WIDTH);
ListView<Class<? extends Component>> componentDisplay = new ListView<>();
componentDisplay.setItems(displayedData);
componentDisplay.setCellFactory(
new Callback<ListView<Class<? extends Component>>, ListCell<Class<? extends Component>>>() {
@Override
public ListCell<Class<? extends Component>> call(ListView<Class<? extends Component>> list) {
return new ComponentCustomizerOption();
}
});
Label title = new Label(listTitle);
this.getChildren().addAll(title, componentDisplay);
}
示例2: ListViewCellFactorySample
import javafx.scene.control.ListView; //导入方法依赖的package包/类
public ListViewCellFactorySample() {
final ListView<Number> listView = new ListView<Number>();
listView.setItems(FXCollections.<Number>observableArrayList(
100.00, -12.34, 33.01, 71.00, 23000.00, -6.00, 0, 42223.00, -12.05, 500.00,
430000.00, 1.00, -4.00, 1922.01, -90.00, 11111.00, 3901349.00, 12.00, -1.00, -2.00,
15.00, 47.50, 12.11
));
listView.setCellFactory(new Callback<ListView<java.lang.Number>, ListCell<java.lang.Number>>() {
@Override public ListCell<Number> call(ListView<java.lang.Number> list) {
return new MoneyFormatCell();
}
});
listView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
getChildren().add(listView);
}
示例3: buildConfigurationUI
import javafx.scene.control.ListView; //导入方法依赖的package包/类
private Node buildConfigurationUI() {
VBox box = new VBox();
box.setPadding(new Insets(10));
CheckBox cb = new CheckBox(MessageBundle.getInstance().getString("homeTimelineCB"));
cb.selectedProperty().addListener((ObservableValue<? extends Boolean> ov, Boolean oldVal, Boolean newVal) -> {
showHomeTimeline = newVal;
});
Label label = new Label(MessageBundle.getInstance().getString("userListLabel") + ":");
ListView<SelectableItem<UserList>> lv = new ListView<>();
lv.setItems(itemList);
lv.setCellFactory(CheckBoxListCell.forListView(item -> item.getSelected()));
VBox.setVgrow(lv, Priority.ALWAYS);
box.getChildren().addAll(cb, label, lv);
showTwitterListSelection();
return box;
}
开发者ID:PacktPublishing,项目名称:Java-9-Programming-Blueprints,代码行数:22,代码来源:TwitterPreferencesController.java
示例4: ComboBoxListViewSample
import javafx.scene.control.ListView; //导入方法依赖的package包/类
public ComboBoxListViewSample() {
ListView<Object> listView = new ListView<>();
listView.getItems().addAll(items);
listView.setEditable(true);
listView.setCellFactory(ComboBoxListCell.forListView(items));
getChildren().add(listView);
}
示例5: TextFieldListViewSample
import javafx.scene.control.ListView; //导入方法依赖的package包/类
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);
}
示例6: ChoiceBoxListViewSample
import javafx.scene.control.ListView; //导入方法依赖的package包/类
public ChoiceBoxListViewSample() {
ListView<Object> listView = new ListView<>();
listView.getItems().addAll(items);
listView.setEditable(true);
listView.setCellFactory(ChoiceBoxListCell.forListView(items));
getChildren().addAll(listView, new Button("Click me"));
}
示例7: createSpriteList
import javafx.scene.control.ListView; //导入方法依赖的package包/类
protected ListView<SpriteDefinition> createSpriteList (ObservableList<SpriteDefinition> collection) {
ListView<SpriteDefinition> list = new ListView<SpriteDefinition>();
list.setItems(collection);
list.setCellFactory(c -> getSpriteCellView());
return list;
}
示例8: StringListInput
import javafx.scene.control.ListView; //导入方法依赖的package包/类
/**
* String List input constructor
*
* @param parameterValues List with all parameters
* @param index Index of the parameter that the input should use.
* @param defaultValue Default value for the list. Expected to be in the form "[string1, string2]" etc.
*/
public StringListInput(List<JPair<String, Object>> parameterValues, int index, String defaultValue) {
// Create HashSet instance and add it to the parameters
set = new HashSet<>();
parameterValues.get(index).setRight(set);
// Create the editable list
ObservableList<String> stringList = FXCollections.observableArrayList();
ListView<String> simpleList = new ListView<>(stringList);
simpleList.setEditable(true);
simpleList.setCellFactory(TextFieldListCell.forListView());
simpleList.setOnEditCommit(t -> simpleList.getItems().set(t.getIndex(), t.getNewValue()));
// Create the add/remove item buttons
Button addBtn = new Button("Add");
addBtn.onActionProperty().setValue(event -> stringList.add("(double click to edit)"));
Button removeBtn = new Button("Remove last");
removeBtn.onActionProperty().setValue(event -> {
ObservableList<String> list = simpleList.getItems();
// Only try to remove if list contains at least 1 item
if (list.size() > 0) {
list.remove(list.size() - 1);
}
});
HBox addRemoveHBox = new HBox();
addRemoveHBox.setSpacing(5);
addRemoveHBox.setAlignment(Pos.CENTER);
addRemoveHBox.getChildren().add(addBtn);
addRemoveHBox.getChildren().add(removeBtn);
// Add a listener to the string list, so when it changes we update the Set
simpleList.getItems().addListener((ListChangeListener<String>) c -> {
// Clear the current set's contents, and add the new ones
set.clear();
set.addAll(simpleList.getItems());
});
// Add buttons to the container
this.setSpacing(5);
this.getChildren().add(simpleList);
this.getChildren().add(addRemoveHBox);
// If there is a default value for the list, add it now
if (!defaultValue.equals("-")) {
// Remove first and last characters (which are expected to be square brackets)
defaultValue = defaultValue.substring(1, defaultValue.length() - 1);
// Split into Strings and add them to the set
String[] strings = defaultValue.split(", ");
// Update the list with the new strings (which also updates the HashSet because of the listener)
simpleList.getItems().addAll(strings);
}
}