当前位置: 首页>>代码示例>>Java>>正文


Java TableView类代码示例

本文整理汇总了Java中javafx.scene.control.TableView的典型用法代码示例。如果您正苦于以下问题:Java TableView类的具体用法?Java TableView怎么用?Java TableView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TableView类属于javafx.scene.control包,在下文中一共展示了TableView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPoint

import javafx.scene.control.TableView; //导入依赖的package包/类
public Point2D getPoint(TableView<?> tableView, int columnIndex, int rowIndex) {
    Set<Node> tableRowCell = tableView.lookupAll(".table-row-cell");
    TableRow<?> row = null;
    for (Node tableRow : tableRowCell) {
        TableRow<?> r = (TableRow<?>) tableRow;
        if (r.getIndex() == rowIndex) {
            row = r;
            break;
        }
    }
    Set<Node> cells = row.lookupAll(".table-cell");
    for (Node node : cells) {
        TableCell<?, ?> cell = (TableCell<?, ?>) node;
        if (tableView.getColumns().indexOf(cell.getTableColumn()) == columnIndex) {
            Bounds bounds = cell.getBoundsInParent();
            Point2D localToParent = cell.localToParent(bounds.getWidth() / 2, bounds.getHeight() / 2);
            Point2D rowLocal = row.localToScene(localToParent, true);
            return rowLocal;
        }
    }
    return null;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:23,代码来源:JavaFXElementPropertyAccessor.java

示例2: scrollToRow

import javafx.scene.control.TableView; //导入依赖的package包/类
@Test public void scrollToRow() throws Throwable {
    Stage primaryStage = getPrimaryStage();
    primaryStage.setWidth(250);
    primaryStage.setHeight(250);
    TableView<?> tableViewNode = (TableView<?>) primaryStage.getScene().getRoot().lookup(".table-view");
    Platform.runLater(() -> {
        tableView.marathon_select("{\"rows\":[10]}");
    });
    new Wait("Wating for rows to be select.") {
        @Override public boolean until() {
            return tableViewNode.getSelectionModel().getSelectedIndex() == 10;
        }
    };
    new Wait("Waiting for the point to be in viewport") {
        @Override public boolean until() {
            Point2D point = getPoint(tableViewNode, 1, 10);
            return tableViewNode.getBoundsInLocal().contains(point);
        }
    };
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:21,代码来源:JavaFXTableViewElementScrollTest.java

示例3: scrollTomnthCell

import javafx.scene.control.TableView; //导入依赖的package包/类
@Test public void scrollTomnthCell() {
    Stage primaryStage = getPrimaryStage();
    primaryStage.setWidth(250);
    primaryStage.setHeight(250);
    TableView<?> tableViewNode = (TableView<?>) primaryStage.getScene().getRoot().lookup(".table-view");
    List<String> columnName = new ArrayList<>();
    Platform.runLater(() -> {
        JavaFXTableCellElement cell = (JavaFXTableCellElement) tableView.findElementByCssSelector(".::mnth-cell(7,3)");
        cell.getPseudoComponent();
        columnName.add(cell.getAttribute("viewColumnName"));
    });
    new Wait("Wating cells column name.") {
        @Override public boolean until() {
            return columnName.size() > 0;
        }
    };
    new Wait("Waiting for the point to be in viewport") {
        @Override public boolean until() {
            return getPoint(tableViewNode, 2, 7) != null;
        }
    };
    Point2D point = getPoint(tableViewNode, 2, 7);
    AssertJUnit.assertTrue(tableViewNode.getBoundsInLocal().contains(point));
    AssertJUnit.assertEquals("Email", columnName.get(0));
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:26,代码来源:JavaFXTableViewElementScrollTest.java

示例4: start

import javafx.scene.control.TableView; //导入依赖的package包/类
public void start(Stage primaryStage) throws Exception {
    FXMLLoader loader = new FXMLLoader();
    loader.setLocation(getLayout("server.fxml"));

    StackPane root = new StackPane();
    root.getChildren().add((Node)loader.load());

    s = new Scene(root, 800, 480);
    primaryStage.setScene(s);
    primaryStage.show();
    this.primaryStage = primaryStage;
    this.table = (TableView<TX>) s.lookup("#table");
    this.model = FXCollections.observableArrayList();
    this.table.setItems(model);
    ObservableList<TableColumn<TX, ?>> cols = this.table.getColumns();

    TableColumn<TX, Integer> id = (TableColumn<TX, Integer>)cols.get(0);
    id.setCellValueFactory(cellData -> cellData.getValue().id.asObject());
    TableColumn<TX, String> pin = (TableColumn<TX, String>)cols.get(1);
    pin.setCellValueFactory(cellData -> cellData.getValue().pin);
    TableColumn<TX, String> desc = (TableColumn<TX, String>)cols.get(2);
    desc.setCellValueFactory(cellData -> cellData.getValue().desc);
    TableColumn<TX, String> status = (TableColumn<TX, String>)cols.get(3);
    status.setCellValueFactory(cellData -> cellData.getValue().status);
    TableColumn<TX, String> amount = (TableColumn<TX, String>)cols.get(4);
    amount.setCellValueFactory(cellData -> cellData.getValue().amount);
    TableColumn<TX, Long> time = (TableColumn<TX, Long>)cols.get(5);
    time.setCellValueFactory(cellData -> cellData.getValue().timeFilled.asObject());

    primaryStage.setOnCloseRequest((WindowEvent event) -> System.exit(0));
    onRequestReceived(-1, "Test TX", new BigDecimal(1));

    CryptoServer server = new CryptoServer(location, this);
    Thread t = new Thread(server);
    t.start();
}
 
开发者ID:Roxas240,项目名称:CryptoPayAPI,代码行数:37,代码来源:Main.java

示例5: VarsPanel

import javafx.scene.control.TableView; //导入依赖的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

示例6: createOrganizationTable

import javafx.scene.control.TableView; //导入依赖的package包/类
private TableView<OrganizationView> createOrganizationTable(ObservableList<OrganizationView> orgas) {
	TableView<OrganizationView> result = new TableView<>(orgas);

	TableColumn<OrganizationView, String> name = new TableColumn<>("Name");
	TableColumn<OrganizationView, String> owned = new TableColumn<>("Owned");
	TableColumn<OrganizationView, Integer> serverCount = new TableColumn<>("Servers");

	name.setCellValueFactory(new PropertyValueFactory<>("name"));
	serverCount.setCellValueFactory(new PropertyValueFactory<>("serverCount"));
	owned.setCellValueFactory(new PropertyValueFactory<>("isOwned"));
	
	serverCount.setMinWidth(70);
	serverCount.setMaxWidth(70);
	owned.setMaxWidth(70);
	owned.setMinWidth(70);
	
	result.getColumns().add(name);
	result.getColumns().add(serverCount);
	result.getColumns().add(owned);

	return result;
}
 
开发者ID:ScreachFr,项目名称:titanium,代码行数:23,代码来源:OrganizationManagerStage.java

示例7: createClassifierTable

import javafx.scene.control.TableView; //导入依赖的package包/类
static <T> TableView<ClassifierResult<T>> createClassifierTable() {
	TableView<ClassifierResult<T>> ret = new TableView<>();
	ret.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

	TableColumn<ClassifierResult<T>, String> tab0 = new TableColumn<>("name");
	tab0.setCellValueFactory(data -> new ReadOnlyObjectWrapper<>(data.getValue().getClassifier().getName()));
	ret.getColumns().add(tab0);

	TableColumn<ClassifierResult<T>, String> tab1 = new TableColumn<>("score");
	tab1.setCellValueFactory(data -> new ReadOnlyObjectWrapper<>(String.format("%.2f", data.getValue().getScore())));
	ret.getColumns().add(tab1);

	TableColumn<ClassifierResult<T>, Double> tab2 = new TableColumn<>("weight");
	tab2.setCellValueFactory(data -> new ReadOnlyObjectWrapper<>(data.getValue().getClassifier().getWeight()));
	ret.getColumns().add(tab2);

	TableColumn<ClassifierResult<T>, String> tab3 = new TableColumn<>("w. score");
	tab3.setCellValueFactory(data -> new ReadOnlyObjectWrapper<>(String.format("%.2f", data.getValue().getScore() * data.getValue().getClassifier().getWeight())));
	ret.getColumns().add(tab3);

	ret.setItems(FXCollections.observableArrayList());

	return ret;
}
 
开发者ID:sfPlayer1,项目名称:Matcher,代码行数:25,代码来源:ClassScoresTab.java

示例8: TableSample

import javafx.scene.control.TableView; //导入依赖的package包/类
public TableSample() {
    final ObservableList<Person> data = FXCollections.observableArrayList(
        new Person("Jacob",     "Smith",    "[email protected]" ),
        new Person("Isabella",  "Johnson",  "[email protected]" ),
        new Person("Ethan",     "Williams", "[email protected]" ),
        new Person("Emma",      "Jones",    "[email protected]" ),
        new Person("Michael",   "Brown",    "[email protected]" )
    );
    TableColumn firstNameCol = new TableColumn();
    firstNameCol.setText("First");
    firstNameCol.setCellValueFactory(new PropertyValueFactory("firstName"));
    TableColumn lastNameCol = new TableColumn();
    lastNameCol.setText("Last");
    lastNameCol.setCellValueFactory(new PropertyValueFactory("lastName"));
    TableColumn emailCol = new TableColumn();
    emailCol.setText("Email");
    emailCol.setMinWidth(200);
    emailCol.setCellValueFactory(new PropertyValueFactory("email"));
    TableView tableView = new TableView();
    tableView.setItems(data);
    tableView.getColumns().addAll(firstNameCol, lastNameCol, emailCol);
    getChildren().add(tableView);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:24,代码来源:TableSample.java

示例9: getVisibleCellAt

import javafx.scene.control.TableView; //导入依赖的package包/类
public TableCell<?, ?> getVisibleCellAt(TableView<?> tableView, int row, int column) {
    Set<Node> lookupAll = getTableCells(tableView);
    TableCell<?, ?> cell = null;
    for (Node node : lookupAll) {
        TableCell<?, ?> cell1 = (TableCell<?, ?>) node;
        TableRow<?> tableRow = cell1.getTableRow();
        TableColumn<?, ?> tableColumn = cell1.getTableColumn();
        if (tableRow.getIndex() == row && tableColumn == tableView.getColumns().get(column)) {
            cell = cell1;
            break;
        }
    }
    if (cell != null) {
        return cell;
    }
    return null;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:18,代码来源:JavaFXElementPropertyAccessor.java

示例10: selectCells

import javafx.scene.control.TableView; //导入依赖的package包/类
@SuppressWarnings("unchecked") public void selectCells(TableView<?> tableView, String value) {
    @SuppressWarnings("rawtypes")
    TableViewSelectionModel selectionModel = tableView.getSelectionModel();
    selectionModel.clearSelection();
    JSONObject cells = new JSONObject(value);
    JSONArray object = (JSONArray) cells.get("cells");
    for (int i = 0; i < object.length(); i++) {
        JSONArray jsonArray = object.getJSONArray(i);
        int rowIndex = Integer.parseInt(jsonArray.getString(0));
        int columnIndex = getColumnIndex(jsonArray.getString(1));
        @SuppressWarnings("rawtypes")
        TableColumn column = tableView.getColumns().get(columnIndex);
        if (getVisibleCellAt(tableView, rowIndex, columnIndex) == null) {
            tableView.scrollTo(rowIndex);
            tableView.scrollToColumn(column);
        }
        selectionModel.select(rowIndex, column);
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:20,代码来源:JavaFXElementPropertyAccessor.java

示例11: btnMapDevicesAction

import javafx.scene.control.TableView; //导入依赖的package包/类
@FXML
private void btnMapDevicesAction()
{
	try
	{
	    FXMLLoader loader = new FXMLLoader(MainDisplay.class.getResource("/fxml/MapDevicesDialog.fxml"));
	    Parent root = loader.load();
	    Scene scene = new Scene(root);
	    Stage stage = new Stage();
	    stage.initModality(Modality.APPLICATION_MODAL);
	    stage.initStyle(StageStyle.UNDECORATED);
	    stage.setScene(scene);
	    stage.show();
	    
	    Node node = scene.lookup("#tblMapDevice");
	    
	    if(node instanceof TableView)
	    {
	    	TableView<Pair<String, String>> table = (TableView)node;
	    	ArrayList<Pair<String, String>> pairList = new ArrayList<>();
	    	
	    	dataContainer.getDeviceMap().entrySet().forEach(entry -> pairList.add(new Pair<String, String>(entry.getKey(), entry.getValue())));
	    	
	    	ObservableList<Pair<String, String>> tableModel = FXCollections.<Pair<String, String>> observableArrayList(pairList);
	    	    	
	    	table.setItems(tableModel);
	    }
	}
	catch(IOException e)
	{
	    e.printStackTrace();
	}
}
 
开发者ID:tengai650,项目名称:SnapDup,代码行数:34,代码来源:MainDisplay.java

示例12: updateItem

import javafx.scene.control.TableView; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked") 
protected void updateItem(String item, boolean empty) {
	super.updateItem(item, empty);
	if (!empty) {
		TableView<DesignVariable> tv = getTableView();
		TableRow<DesignVariable> tr = getTableRow();
		if ((tv != null) && (tr != null))  {
			if (tv.getItems().get(getTableRow().getIndex()).isOutput()) {
				setTextFill(Color.BLUE);
			} else if (tv.getItems().get(getTableRow().getIndex()).getValue().equals("INVALID")) {
				setTextFill(Color.ORANGE);
			} else {
				setTextFill(Color.GREEN);
			}
		} else {
			setTextFill(Color.YELLOW);
		}
		setText(item);
	} else {
		setText("");
	}
}
 
开发者ID:nasa,项目名称:OpenVSP3Plugin,代码行数:24,代码来源:DesignVariableTableCell.java

示例13: getByPseudoElement

import javafx.scene.control.TableView; //导入依赖的package包/类
@Override public List<IJavaFXElement> getByPseudoElement(String selector, Object[] params) {
    if (selector.equals("mnth-cell")) {
        return Arrays.asList(
                new JavaFXTableCellElement(this, ((Integer) params[0]).intValue() - 1, ((Integer) params[1]).intValue() - 1));
    } else if (selector.equals("all-cells")) {
        TableView<?> tableView = (TableView<?>) getComponent();
        int rowCount = tableView.getItems().size();
        int columnCount = tableView.getColumns().size();
        ArrayList<IJavaFXElement> r = new ArrayList<>();
        for (int i = 0; i < rowCount; i++) {
            for (int j = 0; j < columnCount; j++) {
                r.add(new JavaFXTableCellElement(this, i, j));
            }
        }
        return r;
    } else if (selector.equals("select-by-properties")) {
        return findSelectByProperties(new JSONObject((String) params[0]));
    }
    return super.getByPseudoElement(selector, params);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:21,代码来源:JavaFXTableViewElement.java

示例14: scrollMultipleRows

import javafx.scene.control.TableView; //导入依赖的package包/类
@Test public void scrollMultipleRows() {
    Stage primaryStage = getPrimaryStage();
    primaryStage.setWidth(250);
    primaryStage.setHeight(250);
    TableView<?> tableViewNode = (TableView<?>) primaryStage.getScene().getRoot().lookup(".table-view");
    Platform.runLater(() -> {
        tableViewNode.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
        tableView.marathon_select("{\"rows\":[2,9]}");
    });
    new Wait("Wating for rows to be select.") {
        @Override public boolean until() {
            return tableViewNode.getSelectionModel().getSelectedIndices().size() > 1;
        }
    };
    new Wait("Waiting for the point to be in viewport") {
        @Override public boolean until() {
            Point2D point = getPoint(tableViewNode, 2, 9);
            return tableViewNode.getBoundsInLocal().contains(point);
        }
    };
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:22,代码来源:JavaFXTableViewElementScrollTest.java

示例15: updateTableValues

import javafx.scene.control.TableView; //导入依赖的package包/类
private void updateTableValues(ComboBox<String> traceNameComboBox) {
	if (openedWindowsCtr == 0) {
		return;
	}
	int selectedIndex = traceNameComboBox.getSelectionModel().getSelectedIndex();
	if (selectedIndex == -1) {
		return;
	}
	GenericTrace<?> trace = plotData.getAllTraces().get(selectedIndex);
	List<PlotDataTableModel> dataList = new ArrayList<>();
	for (int i = 0; i < trace.getxArray().length; i++) {
		if (trace.getxArray() == null)
			return;
		if (trace.getzArray() == null && trace.getyArray() == null) {
			dataList.add(new PlotDataTableModel(trace.getxArray()[i], 0.0, 0.0));
		} else if (trace.getzArray() == null) {
			dataList.add(new PlotDataTableModel(trace.getxArray()[i], trace.getyArray()[i], 0.0));
		} else {
			dataList.add(new PlotDataTableModel(trace.getxArray()[i], trace.getyArray()[i], trace.getzArray()[i]));
		}
	}
	table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
	table.setItems(FXCollections.observableArrayList(dataList));
}
 
开发者ID:jasrodis,项目名称:javafx-dataviewer,代码行数:25,代码来源:TopMenu.java


注:本文中的javafx.scene.control.TableView类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。