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


Java TableColumn.setCellFactory方法代碼示例

本文整理匯總了Java中javafx.scene.control.TableColumn.setCellFactory方法的典型用法代碼示例。如果您正苦於以下問題:Java TableColumn.setCellFactory方法的具體用法?Java TableColumn.setCellFactory怎麽用?Java TableColumn.setCellFactory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.control.TableColumn的用法示例。


在下文中一共展示了TableColumn.setCellFactory方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: processChoiceBoxColumnName

import javafx.scene.control.TableColumn; //導入方法依賴的package包/類
private TableColumn processChoiceBoxColumnName(String name, JsonArray items){
    TableColumn column = new TableColumn(name);
    column.setCellValueFactory( p -> ((TableColumn.CellDataFeatures<Item, Object>)p).getValue().getStringProperty(name));
    ObservableList list = FXCollections.observableArrayList();
    if(items!=null) list.addAll(items.getList());
    column.setCellFactory(ChoiceBoxTableCell.forTableColumn(list));
    column.setOnEditCommit( t -> {
        int index = ((TableColumn.CellEditEvent<Item, Object>) t).getTablePosition().getRow();
        Item item = ((TableColumn.CellEditEvent<Item, Object>) t).getTableView().getItems().get(index);
        item.setProperty(name,((TableColumn.CellEditEvent<Item, Object>) t).getNewValue());
    });
    columnMap.put(name, column);
    return column;
}
 
開發者ID:whitewoodcity,項目名稱:xbrowser,代碼行數:15,代碼來源:TableView.java

示例2: VarsPanel

import javafx.scene.control.TableColumn; //導入方法依賴的package包/類
public VarsPanel(AppSession session) {
    this.session = session;        
    table = new TableView();
    table.setPrefWidth(300);
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    setCenter(table);
    TableColumn nameCol = new TableColumn("Variable");
    nameCol.setMinWidth(120);
    nameCol.setMaxWidth(250);
    nameCol.setCellValueFactory(new PropertyValueFactory("name"));
    nameCol.setCellFactory(c -> new StringTooltipCell());
    TableColumn typeCol = new TableColumn("Type");
    typeCol.setMinWidth(45);
    typeCol.setMaxWidth(60);
    typeCol.setCellValueFactory(new PropertyValueFactory("type"));
    TableColumn<Var, ScriptValue> valueCol = new TableColumn("Value");
    valueCol.setCellValueFactory(c -> new ReadOnlyObjectWrapper(c.getValue().getValue()));        
    valueCol.setCellFactory(c -> new VarValueCell());
    table.getColumns().addAll(nameCol, typeCol, valueCol);
    table.setItems(session.getVars());
    table.setRowFactory(tv -> {
        TableRow<Var> row = new TableRow<>();
        row.setOnMouseClicked(e -> {
            if (e.getClickCount() == 2 && !row.isEmpty()) {
                Var var = row.getItem();
                session.logVar(var);
            }
        });
        return row ;
    });        
}
 
開發者ID:intuit,項目名稱:karate,代碼行數:32,代碼來源:VarsPanel.java

示例3: processComboBoxColumnName

import javafx.scene.control.TableColumn; //導入方法依賴的package包/類
private TableColumn processComboBoxColumnName(String name, JsonArray items){
    TableColumn column = new TableColumn(name);
    column.setCellValueFactory( p -> ((TableColumn.CellDataFeatures<Item, Object>)p).getValue().getStringProperty(name));
    ObservableList list = FXCollections.observableArrayList();
    if(items!=null) list.addAll(items.getList());
    column.setCellFactory(ComboBoxTableCell.forTableColumn(list));
    column.setOnEditCommit( t -> {
        int index = ((TableColumn.CellEditEvent<Item, Object>) t).getTablePosition().getRow();
        Item item = ((TableColumn.CellEditEvent<Item, Object>) t).getTableView().getItems().get(index);
        item.setProperty(name,((TableColumn.CellEditEvent<Item, Object>) t).getNewValue());
    });
    columnMap.put(name, column);
    return column;
}
 
開發者ID:whitewoodcity,項目名稱:xbrowser,代碼行數:15,代碼來源:TableView.java

示例4: tableColumns

import javafx.scene.control.TableColumn; //導入方法依賴的package包/類
public static void tableColumns(final Visitor v, List<? extends TableColumn<?, ?>> addedSubList) {
	for(int i = 0; i < addedSubList.size(); i++){
		final TableColumn<?,?> col = addedSubList.get(i);
		
		col.setCellFactory(new DnDTableCellFactory(v, col.getCellFactory()));
		col.cellFactoryProperty().addListener(new ChangeListener<Callback>() {
			@Override
			public void changed(ObservableValue<? extends Callback> observable, Callback oldValue,
					Callback newValue) {
				if(!(newValue instanceof DnDTableCellFactory)){
					col.setCellFactory(new DnDTableCellFactory(v, col.getCellFactory()));
				}
			}
		});
	}
}
 
開發者ID:coalang-soft,項目名稱:dragdropfx,代碼行數:17,代碼來源:DnDPrepare.java

示例5: createColumns

import javafx.scene.control.TableColumn; //導入方法依賴的package包/類
private void createColumns() {
    TableColumn<RequestEntry, String> eventTypeCol = new TableColumn("Type");
    eventTypeCol.setMinWidth(100);
    eventTypeCol.setCellValueFactory(new PropertyValueFactory<>("eventType"));
    eventTypeCol.setSortable(false);

    TableColumn<RequestEntry, String> eventNameCol = new TableColumn("Name");
    eventNameCol.setMinWidth(100);
    eventNameCol.setCellValueFactory(new PropertyValueFactory<>("eventName"));
    eventNameCol.setSortable(false);

    TableColumn<RequestEntry, String> eventDateTimeCol = new TableColumn("Time");
    eventDateTimeCol.setMinWidth(200);
    eventDateTimeCol.setCellValueFactory(new PropertyValueFactory<>("eventDateTime"));
    eventDateTimeCol.setSortable(false);

    TableColumn<RequestEntry, String> eventLocationCol = new TableColumn("Location");
    eventLocationCol.setMinWidth(100);
    eventLocationCol.setCellValueFactory(new PropertyValueFactory<>("eventLocation"));
    eventLocationCol.setSortable(false);

    TableColumn<RequestEntry, String> eventConductorCol = new TableColumn("Conductor");
    eventConductorCol.setMinWidth(100);
    eventConductorCol.setCellValueFactory(new PropertyValueFactory<>("eventConductor"));
    eventConductorCol.setSortable(false);

    TableColumn<RequestEntry, RequestTypeGUI> requestTypeCol = new TableColumn("Request");
    requestTypeCol.setCellFactory((param) -> new RequestRadioButtonCell<>(EnumSet.allOf(RequestTypeGUI.class)));
    requestTypeCol.setCellValueFactory(new PropertyValueFactory<>("requestType"));
    requestTypeCol.setSortable(false);

    TableColumn<RequestEntry, TextField> eventDescriptionCol = new TableColumn("Description");
    eventDescriptionCol.setMinWidth(300);
    eventDescriptionCol.setCellValueFactory(new PropertyValueFactory<RequestEntry, TextField>("requestDescription"));
    eventDescriptionCol.setResizable(false);
    eventDescriptionCol.setSortable(false);

    table.getColumns().addAll(eventTypeCol, eventNameCol, eventDateTimeCol, eventLocationCol, eventConductorCol, requestTypeCol, eventDescriptionCol);
}
 
開發者ID:ITB15-S4-GroupD,項目名稱:Planchester,代碼行數:40,代碼來源:EditRequestsController.java

示例6: LogPane

import javafx.scene.control.TableColumn; //導入方法依賴的package包/類
public LogPane() {
    super();
    table = new TableView<>();

    TableColumn<LogItem, StatusType> statusColumn = new TableColumn<>("Status");
    statusColumn.setCellValueFactory(new PropertyValueFactory<>("status"));
    statusColumn.prefWidthProperty().bind(Bindings.multiply(0.1, table.widthProperty()));
    statusColumn.setCellFactory(col -> new StatusTypeCell());

    TableColumn<LogItem, ActionType> actionColumn = new TableColumn<>("Action");
    actionColumn.setCellValueFactory(new PropertyValueFactory<>("action"));
    actionColumn.prefWidthProperty().bind(Bindings.multiply(0.1, table.widthProperty()));
    actionColumn.setCellFactory(col -> new ActionTypeCell());

    TableColumn<LogItem, LocalDateTime> timeColumn = new TableColumn<>("Time");
    timeColumn.setCellValueFactory(new PropertyValueFactory<>("time"));
    timeColumn.prefWidthProperty().bind(Bindings.multiply(0.2, table.widthProperty()));
    timeColumn.setCellFactory(col -> new TimeCell());

    TableColumn<LogItem, String> calendarColumn = new TableColumn<>("Calendar");
    calendarColumn.setCellValueFactory(new PropertyValueFactory<>("calendar"));
    calendarColumn.prefWidthProperty().bind(Bindings.multiply(0.2, table.widthProperty()));

    TableColumn<LogItem, String> descriptionColumn = new TableColumn<>("Description");
    descriptionColumn.setCellValueFactory(new PropertyValueFactory<>("description"));
    descriptionColumn.prefWidthProperty().bind(Bindings.multiply(0.4, table.widthProperty()));

    filteredData = new FilteredList<>(items);
    SortedList<LogItem> sortedData = new SortedList<>(filteredData);
    sortedData.comparatorProperty().bind(table.comparatorProperty());

    table.getColumns().add(statusColumn);
    table.getColumns().add(actionColumn);
    table.getColumns().add(timeColumn);
    table.getColumns().add(calendarColumn);
    table.getColumns().add(descriptionColumn);
    table.setTableMenuButtonVisible(true);
    table.setItems(sortedData);
    table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:41,代碼來源:LogPane.java

示例7: initProcessTable

import javafx.scene.control.TableColumn; //導入方法依賴的package包/類
private void initProcessTable() {
    ObservableList<TableColumn<Process, ?>> processCols = processTable.getColumns();
    processCols.get(0).setCellValueFactory(new PropertyValueFactory<>("status"));
    TableColumn<Process,Double> processCol = new TableColumn<>("進度");
    processCol.setPrefWidth(475);
    processCol.setCellValueFactory(new PropertyValueFactory<>("progress"));
    processCol.setCellFactory(ProgressBarTableCell.forTableColumn());
    processCols.set(1,processCol);
    processCols.get(2).setCellValueFactory(new PropertyValueFactory<>("percent"));
    processCols.get(3).setCellValueFactory(new PropertyValueFactory<>("lastUpdate"));
}
 
開發者ID:cuiods,項目名稱:WIFIProbe,代碼行數:12,代碼來源:IndexController.java

示例8: initStatusTable

import javafx.scene.control.TableColumn; //導入方法依賴的package包/類
private void initStatusTable() {
    ObservableList<TableColumn<ProbeStatus, ?>> statusColumns = statusTable.getColumns();
    statusColumns.get(0).setCellValueFactory(new PropertyValueFactory<>("id"));
    statusColumns.get(1).setCellValueFactory(new PropertyValueFactory<>("status"));
    statusColumns.get(2).setCellValueFactory(new PropertyValueFactory<>("ip"));
    TableColumn<ProbeStatus,String> actionCol = new TableColumn<>("操作");
    actionCol.setPrefWidth(250);
    actionCol.setCellValueFactory(new PropertyValueFactory<>("DUMMY"));
    actionCol.setCellFactory(param -> new TableCell<ProbeStatus,String>() {
        final Button btn = new Button("管理");
        @Override
        public void updateItem(String item, boolean empty) {
            super.updateItem(item, empty);
            if (empty) {
                setGraphic(null);
                setText(null);
            } else {
                btn.setOnAction(event -> {
                    ProbeStatus probeStatus = getTableView().getItems().get(getIndex());
                    try {
                        URI uri = new URI(probeStatus.getIp());
                        Desktop.getDesktop().browse(uri);
                    } catch (URISyntaxException | IOException e) {
                        e.printStackTrace();
                    }
                });
                setGraphic(btn);
                setText(null);
            }
        }
    });
    statusColumns.add(actionCol);
}
 
開發者ID:cuiods,項目名稱:WIFIProbe,代碼行數:34,代碼來源:IndexController.java

示例9: processStringColumnName

import javafx.scene.control.TableColumn; //導入方法依賴的package包/類
private TableColumn processStringColumnName(String name){
    TableColumn column = new TableColumn(name);
    column.setCellValueFactory( p -> ((TableColumn.CellDataFeatures<Item, Object>)p).getValue().getStringProperty(name));
    column.setCellFactory(TextFieldTableCell.forTableColumn());
    column.setOnEditCommit( t -> {
        int index = ((TableColumn.CellEditEvent<Item, Object>) t).getTablePosition().getRow();
        Item item = ((TableColumn.CellEditEvent<Item, Object>) t).getTableView().getItems().get(index);
        item.setProperty(name,((TableColumn.CellEditEvent<Item, Object>) t).getNewValue());
            });
    columnMap.put(name, column);
    return column;
}
 
開發者ID:whitewoodcity,項目名稱:xbrowser,代碼行數:13,代碼來源:TableView.java

示例10: processCheckBoxColumnName

import javafx.scene.control.TableColumn; //導入方法依賴的package包/類
private TableColumn processCheckBoxColumnName(String name){
    TableColumn column = new TableColumn(name);
    column.setCellValueFactory( p -> ((TableColumn.CellDataFeatures<Item, Boolean>)p).getValue().getBooleanProperty(name));
    column.setCellFactory(CheckBoxTableCell.forTableColumn(column));
    column.setOnEditCommit( t -> {
        int index = ((TableColumn.CellEditEvent<Item, Boolean>) t).getTablePosition().getRow();
        Item item = ((TableColumn.CellEditEvent<Item, Boolean>) t).getTableView().getItems().get(index);
        item.setProperty(name,((TableColumn.CellEditEvent<Item, Boolean>) t).getNewValue());
    });
    columnMap.put(name, column);
    return column;
}
 
開發者ID:whitewoodcity,項目名稱:xbrowser,代碼行數:13,代碼來源:TableView.java

示例11: createRightPane

import javafx.scene.control.TableColumn; //導入方法依賴的package包/類
@SuppressWarnings({ "rawtypes", "unchecked" }) private void createRightPane() {
    annotationTable.getSelectionModel().getSelectedItems().addListener(new ListChangeListener<Annotation>() {
        @Override public void onChanged(javafx.collections.ListChangeListener.Change<? extends Annotation> c) {
            drawGraphics();
            markSelected();
        }
    });
    annotationTable.setEditable(edit);
    annotationTable.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
    annotationTable.addEventHandler(KeyEvent.KEY_PRESSED, (event) -> {
        if (event.getCode() == KeyCode.DELETE || event.getCode() == KeyCode.BACK_SPACE) {
            removeAnnotation();
        }
    });
    TableColumn<Annotation, String> messageColumn = new TableColumn<Annotation, String>("Annotation");
    PropertyValueFactory<Annotation, String> value = new PropertyValueFactory<>("text");
    messageColumn.setCellValueFactory(value);
    messageColumn.setCellFactory(new Callback<TableColumn<Annotation, String>, TableCell<Annotation, String>>() {
        @Override public TableCell<Annotation, String> call(TableColumn<Annotation, String> param) {
            return new TextAreaTableCell();
        }
    });
    messageColumn.prefWidthProperty().bind(annotationTable.widthProperty().subtract(25));

    TableColumn<Annotation, String> numCol = new TableColumn<>("#");
    numCol.setCellFactory(new Callback<TableColumn<Annotation, String>, TableCell<Annotation, String>>() {
        @Override public TableCell<Annotation, String> call(TableColumn<Annotation, String> p) {
            return new TableCell() {
                @Override protected void updateItem(Object item, boolean empty) {
                    super.updateItem(item, empty);
                    setGraphic(null);
                    setText(empty ? null : getIndex() + 1 + "");
                }
            };
        }
    });
    numCol.setPrefWidth(25);

    annotationTable.setItems(annotations);
    annotationTable.getColumns().addAll(numCol, messageColumn);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:42,代碼來源:ImagePanel.java

示例12: initLogTable

import javafx.scene.control.TableColumn; //導入方法依賴的package包/類
@SuppressWarnings({ "rawtypes", "unchecked" }) private void initLogTable() {
    logTable.setId("logTable");
    TableColumn<LogRecord, Integer> iconColumn = new TableColumn<>("");
    iconColumn.prefWidthProperty().bind(logTable.widthProperty().multiply(0.05));
    iconColumn.setCellValueFactory(new PropertyValueFactory<>("type"));
    iconColumn.setCellFactory(new Callback<TableColumn<LogRecord, Integer>, TableCell<LogRecord, Integer>>() {
        @Override public TableCell call(TableColumn<LogRecord, Integer> param) {
            return new IconTableCell();
        }
    });

    TableColumn<LogRecord, String> messageColumn = new TableColumn<>("Message");
    messageColumn.setCellValueFactory(new PropertyValueFactory<>("message"));
    messageColumn.prefWidthProperty().bind(logTable.widthProperty().multiply(0.50));

    TableColumn<LogRecord, String> moduleColumn = new TableColumn<>("Module");
    moduleColumn.setCellValueFactory(new PropertyValueFactory<>("module"));
    moduleColumn.prefWidthProperty().bind(logTable.widthProperty().multiply(0.195));

    TableColumn<LogRecord, String> dateColumn = new TableColumn<>("Date");
    dateColumn.setCellValueFactory(new PropertyValueFactory<>("date"));
    dateColumn.prefWidthProperty().bind(logTable.widthProperty().multiply(0.25));

    logList.addListener(new ListChangeListener<LogRecord>() {
        @Override public void onChanged(javafx.collections.ListChangeListener.Change<? extends LogRecord> c) {
            if (logList.size() == 0) {
                clearButton.setDisable(true);
            } else {
                clearButton.setDisable(false);
            }
        }
    });

    logTable.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
        if (newValue != null && newValue.getDescription() != null) {
            showMessageButton.setDisable(false);
        } else {
            showMessageButton.setDisable(true);
        }
    });
    logTable.setRowFactory(e -> {
        TableRow<LogRecord> tableRow = new TableRow<>();
        tableRow.setOnMouseClicked(event -> {
            if (event.getClickCount() == 2 && !tableRow.isEmpty()) {
                LogRecord rowData = tableRow.getItem();
                if (rowData.getDescription() != null) {
                    showMessage(rowData);
                }
            }
        });
        return tableRow;
    });

    errorButton.setSelected(true);
    FilteredList<LogRecord> filtered = logList.filtered(new Predicate<LogRecord>() {
        @Override public boolean test(LogRecord t) {
            if (t.getType() == ILogger.ERROR || t.getType() == ILogger.MESSAGE) {
                return true;
            }
            return false;
        }
    });
    logTable.setItems(filtered);
    logTable.refresh();
    logTable.getColumns().addAll(iconColumn, messageColumn, moduleColumn, dateColumn);
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:67,代碼來源:LogView.java


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