當前位置: 首頁>>代碼示例>>Java>>正文


Java ListView.setCellFactory方法代碼示例

本文整理匯總了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);
}
 
開發者ID:LtubSalad,項目名稱:voogasalad-ltub,代碼行數:18,代碼來源:ComponentSelectorPane.java

示例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);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:19,代碼來源:ListViewCellFactorySample.java

示例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);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:8,代碼來源:ComboBoxListViewSample.java

示例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);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:11,代碼來源:TextFieldListViewSample.java

示例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"));
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:8,代碼來源:ChoiceBoxListViewSample.java

示例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;
}
 
開發者ID:tomrom95,項目名稱:GameAuthoringEnvironment,代碼行數:7,代碼來源:SideBarDisplay.java

示例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);
    }
}
 
開發者ID:scify,項目名稱:jedai-ui,代碼行數:66,代碼來源:StringListInput.java


注:本文中的javafx.scene.control.ListView.setCellFactory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。