本文整理汇总了Java中com.sun.javafx.scene.control.skin.TableViewSkin类的典型用法代码示例。如果您正苦于以下问题:Java TableViewSkin类的具体用法?Java TableViewSkin怎么用?Java TableViewSkin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TableViewSkin类属于com.sun.javafx.scene.control.skin包,在下文中一共展示了TableViewSkin类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scrollUp
import com.sun.javafx.scene.control.skin.TableViewSkin; //导入依赖的package包/类
private void scrollUp(int index) {
TableViewSkin<?> ts = (TableViewSkin<?>) tableDots.getSkin();
VirtualFlow<?> vf = (VirtualFlow<?>) ts.getChildren().get(1);
int first = vf.getFirstVisibleCellWithinViewPort().getIndex();
int last = vf.getLastVisibleCellWithinViewPort().getIndex();
if (index <= (last + first) / 2) {
vf.scrollTo(index - (last - first) / 2);
ts = (TableViewSkin<?>) tableDots.getSkin();
vf = (VirtualFlow<?>) ts.getChildren().get(1);
first = vf.getFirstVisibleCellWithinViewPort().getIndex();
last = vf.getLastVisibleCellWithinViewPort().getIndex();
}
}
示例2: scrollDown
import com.sun.javafx.scene.control.skin.TableViewSkin; //导入依赖的package包/类
private void scrollDown(int index) {
TableViewSkin<?> ts = (TableViewSkin<?>) tableDots.getSkin();
VirtualFlow<?> vf = (VirtualFlow<?>) ts.getChildren().get(1);
int first = vf.getFirstVisibleCellWithinViewPort().getIndex();
int last = vf.getLastVisibleCellWithinViewPort().getIndex();
if (index >= (last + first) / 2) {
vf.scrollTo(index - ((last - first) / 2));
ts = (TableViewSkin<?>) tableDots.getSkin();
vf = (VirtualFlow<?>) ts.getChildren().get(1);
first = vf.getFirstVisibleCellWithinViewPort().getIndex();
last = vf.getLastVisibleCellWithinViewPort().getIndex();
}
}
示例3: initialize
import com.sun.javafx.scene.control.skin.TableViewSkin; //导入依赖的package包/类
@Override
public void initialize(URL location, ResourceBundle resources) {
table.setSelectionModel(null);
Platform.runLater(() -> {
TableViewSkin tableSkin = (TableViewSkin) table.getSkin();
virtualFlow = (VirtualFlow) tableSkin.getChildren().get(1);
});
}
示例4: getVisibleRows
import com.sun.javafx.scene.control.skin.TableViewSkin; //导入依赖的package包/类
/**
* THis is a total hack. We need it as scrollTo jumps the selected row to the top
* of the table. Jarring if the row is already visible. As a workaround, we only
* scroll if the row isn't already visible
* @return A 2 element ray with the start and end index of visible rows
*/
private int[] getVisibleRows() {
// TableView<Annotation> tableView = getTableView();
// // TODO this does not work in Java 9
// // See https://stackoverflow.com/questions/46474385/how-to-find-the-indices-of-the-visible-rows-in-a-tableview-in-javafx-9/46474693#46474693
TableViewSkin<?> skin = (TableViewSkin<?>) tableView.getSkin();
if (skin == null) return new int[] {0, 0};
VirtualFlow<?> flow = (VirtualFlow<?>) skin.getChildren().get(1);
int idxFirst;
int idxLast;
if (flow != null &&
flow.getFirstVisibleCellWithinViewPort() != null &&
flow.getLastVisibleCellWithinViewPort() != null) {
idxFirst = flow.getFirstVisibleCellWithinViewPort().getIndex();
if (idxFirst > tableView.getItems().size()) {
idxFirst = tableView.getItems().size() - 1;
}
idxLast = flow.getLastVisibleCellWithinViewPort().getIndex();
if (idxLast > tableView.getItems().size()) {
idxLast = tableView.getItems().size() - 1;
}
}
else {
idxFirst = 0;
idxLast = 0;
}
return new int[]{idxFirst, idxLast};
// This TableViewExt appears to be buggy
//return tableViewExt.getVisibleRows();
}
示例5: getVirtualFlow
import com.sun.javafx.scene.control.skin.TableViewSkin; //导入依赖的package包/类
private static VirtualFlow<?> getVirtualFlow(TableView table) {
TableViewSkin<?> skin = (TableViewSkin) table.getSkin();
if (skin == null) {
return null;
}
return (VirtualFlow) skin.getChildren().get(1);
}
示例6: getReplaceTableHeaderImplementationButton
import com.sun.javafx.scene.control.skin.TableViewSkin; //导入依赖的package包/类
Node getReplaceTableHeaderImplementationButton() {
Button replaceButton = new Button("Replace skin implementation");
replaceButton.setId(REPLACE_SKIN_IMPLEMENTATION_BUTTON_ID);
replaceButton.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
testedTableView.setSkin(new TableViewSkin(testedTableView) {
@Override
public String toString() {
return "CUSTOM " + super.toString();
}
@Override
protected TableHeaderRow createTableHeaderRow() {
return new TableHeaderRow(this) {
@Override
protected NestedTableColumnHeader createRootHeader() {
return new NestedTableColumnHeader((TableViewSkin) testedTableView.getSkin(), null) {
@Override
protected TableColumnHeader createTableColumnHeader(TableColumnBase col) {
if (col.getColumns().isEmpty()) {
final TableColumnHeader tableColumnHeader = new TableColumnHeader(getTableViewSkin(), col);
tableColumnHeader.setId(CUSTOM_IMPLEMENTATION_MARKER);
return tableColumnHeader;
} else {
final NestedTableColumnHeader nestedTableColumnHeader = new NestedTableColumnHeader(getTableViewSkin(), col);
nestedTableColumnHeader.setId(CUSTOM_IMPLEMENTATION_MARKER);
return nestedTableColumnHeader;
}
}
};
}
};
}
});
}
});
return replaceButton;
}
示例7: updateTableViewSkin
import com.sun.javafx.scene.control.skin.TableViewSkin; //导入依赖的package包/类
private void updateTableViewSkin() {
CTableView<T> tableView = (CTableView<T>) getSkinnable().getTableView();
if (tableView.getSkin() instanceof TableViewSkin) {
tableViewSkin = (CTableViewSkin) tableView.getSkin();
}
}
示例8: configureTable
import com.sun.javafx.scene.control.skin.TableViewSkin; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void configureTable() {
final ObservableList<MyDomain> data = FXCollections.observableArrayList(
new MyDomain("First Row","This is for check."),
new MyDomain("Second Row","This is for check.")
);
TableView<MyDomain> tableView = new TableView<MyDomain>();
tableView.getStyleClass().add("myTable");
tableView.setItems(data);
TableColumn<MyDomain, String> column1 = new TableColumn<GhostColumnRemover.MyDomain, String>("Title");
column1.setCellValueFactory(new PropertyValueFactory<MyDomain, String>("name"));
TableColumn<MyDomain, String> column2 = new TableColumn<GhostColumnRemover.MyDomain, String>("Description");
column2.setCellValueFactory(new PropertyValueFactory<MyDomain, String>("description"));
column2.setCellFactory(new Callback<TableColumn<MyDomain,String>, TableCell<MyDomain,String>>() {
@Override
public TableCell<MyDomain, String> call(TableColumn<MyDomain, String> paramP) {
return new TableCell<GhostColumnRemover.MyDomain, String>(){
@Override
protected void updateItem(String paramT, boolean paramBoolean) {
super.updateItem(paramT, paramBoolean);
if(!isEmpty()){
setGraphic(new Label(paramT));
}
this.getStyleClass().add("last-table-cell");
TableViewSkin<MyDomain> skin = (TableViewSkin<MyDomain>)this.getTableView().getSkin();
// System.out.println(skin.getChildren());
// [[email protected][styleClass=column-header-background],
// [email protected], [email protected][styleClass=column-overlay], [email protected][styleClass=column-resize-line]]
StackPane headerrow = (StackPane)skin.getChildren().get(0);
/* System.out.println(headerrow.getChildren());
[[email protected][styleClass=nested-column-header],
[email protected][styleClass=filler],
[email protected][styleClass=show-hide-columns-button],
[email protected][styleClass=column-drag-header]]
*/
TableColumnHeader head = (TableColumnHeader)headerrow.getChildren().get(0);
System.out.println(headerrow.getChildren().get(0));
head.getStyleClass().add("my-column1");
TableColumnHeader firstno = (TableColumnHeader)head.getChildren().get(0);
firstno.getStyleClass().add("my-column");
VirtualFlow flow = (VirtualFlow)skin.getChildren().get(1);
System.out.println("** "+flow.getChildrenUnmodifiable());
}
};
}
});
tableView.getColumns().addAll(column1, column2);
this.root.getChildren().add(tableView);
}