本文整理汇总了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;
}
示例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 ;
});
}
示例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;
}
示例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()));
}
}
});
}
}
示例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);
}
示例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);
}
示例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"));
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}