本文整理汇总了Java中org.controlsfx.control.GridCell类的典型用法代码示例。如果您正苦于以下问题:Java GridCell类的具体用法?Java GridCell怎么用?Java GridCell使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GridCell类属于org.controlsfx.control包,在下文中一共展示了GridCell类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showContent
import org.controlsfx.control.GridCell; //导入依赖的package包/类
/**
* Method for generate file items for fileBrowser and add it into container(temporary realization)
*/
private void showContent() {
ObservableList<FileItem> list = FXCollections.observableArrayList();
GridView<FileItem> myGrid = new GridView<>(list);
myGrid.setCellFactory(gridView -> new GridCell<FileItem>() {
@Override
public void updateItem(FileItem item, boolean empty) {
if (empty || item == null) {
setText(null);
setGraphic(null);
} else {
//setText(item.getName());
setGraphic(item);
}
}
});
list.addAll(new FileItem("icon", "Folder1"),
new FileItem("icon", "Documents"),
new FileItem("icon", "WorkFiles"),
new FileItem("icon", "Projects"));
container.getChildren().add(myGrid);
}
示例2: onStart
import org.controlsfx.control.GridCell; //导入依赖的package包/类
@Override
public void onStart() {
root.prefWidthProperty().bind(Main.mainController.contentBox.widthProperty());
root.prefHeightProperty().bind(Main.mainController.contentBox.heightProperty());
gridView.setCellHeight(192);
gridView.setCellWidth(192);
gridView.setHorizontalCellSpacing(6);
gridView.setVerticalCellSpacing(6);
gridView.setCellFactory(param -> {
GridCell<Instance> cell = new GridCell<>();
cell.itemProperty().addListener((obs, oldItem, newItem) -> {
if (newItem != null) {
cell.setGraphic(new InstanceTile(newItem));
}
});
cell.emptyProperty().addListener((obs, wasEmpty, isEmpty) -> {
if (isEmpty) {
cell.setGraphic(null);
}
});
cell.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
return cell;
});
new Thread(() -> {
ObservableList<Instance> instances = InstanceManager.getInstances();
MiscUtil.runLaterIfNeeded(() -> gridView.setItems(instances));
}).start();
ContextMenu menu = new ContextMenu();
MenuItem open = new MenuItem("Open Instance Folder");
menu.getItems().addAll(open);
open.setOnAction(event -> OperatingSystem.openWithSystem(Constants.INSTANCEDIR));
gridView.setContextMenu(menu);
}
示例3: fetchVisibleCellRange
import org.controlsfx.control.GridCell; //导入依赖的package包/类
/**
* Gets the visible cell range in this GridView viewport
* @return
*/
private IndexRange fetchVisibleCellRange(){
IndexRange outRange = null;
try {
final VirtualFlow vf = getVirtualFlow();
if(vf != null){
final IndexedCell firstVisibleRow = vf.getFirstVisibleCell();
final IndexedCell lastVisibleRow = vf.getLastVisibleCell();
if(firstVisibleRow != null && lastVisibleRow != null){
final ObservableList<Node> firsts = firstVisibleRow.getChildrenUnmodifiable();
final GridCell firstVisibleCell = firsts.size() > 0 ? (GridCell)firsts.get(0) : null;
final ObservableList<Node> lasts = lastVisibleRow.getChildrenUnmodifiable();
final GridCell lastVisibleCell = lasts.size() > 0 ? (GridCell)lasts.get(lasts.size()-1) : null;
outRange = new IndexRange(
firstVisibleCell != null ? firstVisibleCell.getIndex() : 0,
lastVisibleCell != null ? lastVisibleCell.getIndex() : 0);
}
}
} catch (IllegalArgumentException e) {
logger.error(e);
}
if(outRange == null){
outRange = IndexRange.Undefined;
}
return outRange;
}