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


Java TableColumn.setPrefWidth方法代码示例

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


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

示例1: initTable

import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
/**
 * 初始化配置table
 */
public void initTable() {
	LOG.debug("初始化配置信息表格...");
	ObservableList<HistoryConfigCVF> data = null;
	try {
		data = getHistoryConfig();
	} catch (Exception e) {
		tblConfigInfo.setPlaceholder(new Label("加载配置文件失败!失败原因:\r\n" + e.getMessage()));
		LOG.error("初始化配置信息表格出现异常!!!" + e);
	}

	TableColumn<HistoryConfigCVF, String> tdInfo = new TableColumn<HistoryConfigCVF, String>("配置信息文件名");
	TableColumn<HistoryConfigCVF, String> tdOperation = new TableColumn<HistoryConfigCVF, String>("操作");

	tdInfo.setPrefWidth(320);
	tdInfo.setCellValueFactory(new PropertyValueFactory<>("name"));

	tdOperation.setPrefWidth(198);
	tdOperation.setCellValueFactory(new PropertyValueFactory<>("hbox"));

	tblConfigInfo.getColumns().add(tdInfo);
	tblConfigInfo.getColumns().add(tdOperation);

	tblConfigInfo.setItems(data);
	LOG.debug("初始化配置信息完成!");
}
 
开发者ID:shenzhenMirren,项目名称:vertx-generator,代码行数:29,代码来源:HistoryConfigController.java

示例2: MovieTableView

import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
public MovieTableView() {

        TableColumn<Movie, String> titleColumn = new TableColumn<>("Title");
        titleColumn.setPrefWidth(300);
        titleColumn.setCellValueFactory(new PropertyValueFactory<>("title"));

        TableColumn<Movie, Integer> yearColumn = new TableColumn<>("Year");
        yearColumn.setPrefWidth(80);
        yearColumn.setCellValueFactory(new PropertyValueFactory<>("year"));

        TableColumn<Movie, String> genreColumn = new TableColumn<>("Genre");
        genreColumn.setPrefWidth(140);
        genreColumn.setCellValueFactory(new PropertyValueFactory<>("genre"));

        TableColumn<Movie, Integer> directorColumn = new TableColumn<>("Director");
        directorColumn.setPrefWidth(140);
        directorColumn.setCellValueFactory(new PropertyValueFactory<>("director"));

        TableColumn<Movie, Integer> ratingColumn = new TableColumn<>("Rating");
        ratingColumn.setPrefWidth(120);
        ratingColumn.setCellValueFactory(new PropertyValueFactory<>("rating"));

        getColumns().setAll(titleColumn, yearColumn, genreColumn, directorColumn, ratingColumn);
    }
 
开发者ID:hendrikebbers,项目名称:ExtremeGuiMakeover,代码行数:25,代码来源:MovieTableView.java

示例3: 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

示例4: 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

示例5: 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

示例6: getPane

import javafx.scene.control.TableColumn; //导入方法依赖的package包/类
public BorderPane getPane() {
	TableView<Details> table = new TableView<Details>();
	PieChart chart =new PieChart() ;
	ObservableList<Details> list = FXCollections.observableArrayList();
	TableColumn<Details, String> name = new TableColumn<>("Name");
	name.setPrefWidth(100);
	TableColumn<Details, String> todayExpense = new TableColumn<>("Today Expense");
	todayExpense.setPrefWidth(105);
	TableColumn<Details, String> todayUnits = new TableColumn<>("Today Units");
	todayUnits.setPrefWidth(100);
	TableColumn<Details, String> totalExpense = new TableColumn<>("Total Expense");
	totalExpense.setPrefWidth(100);
	TableColumn<Details, String> totalUnits = new TableColumn<>("Total Units");
	totalUnits.setPrefWidth(100);
	name.setCellValueFactory(new PropertyValueFactory<Details,String>("name"));
	todayExpense.setCellValueFactory(new PropertyValueFactory<Details,String>("todayExpense"));
	todayUnits.setCellValueFactory(new PropertyValueFactory<Details,String>("todayUnits"));
	totalExpense.setCellValueFactory(new PropertyValueFactory<Details,String>("totalExpense"));
	totalUnits.setCellValueFactory(new PropertyValueFactory<Details,String>("totalUnits"));
	table.getColumns().addAll(name,todayExpense,todayUnits,totalExpense,totalUnits);
	Details detail1 = new Details("Lights", "3400", "40", "6000", "67");
	list.addAll(detail1, new Details("Refrigerator", "40000", "40", "8000", "67"),new Details("Television", "3000", "40", "5000", "67"),new Details("Fans", "300", "20", "600", "47"),new Details("A.C", "7000", "80", "10000", "100"),new Details("Oven", "3400", "50", "6500", "70"),new Details("Washing Machine", "3700", "60", "6500", "80"));
	table.setItems(list);
	ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList(
			new PieChart.Data("Device 1", 200),
			new PieChart.Data("Device 2", 130),
			new PieChart.Data("Device 3", 100),
			new PieChart.Data("Device 4", 200)
		
			);
	chart.setLabelsVisible(false);
	chart.setLegendVisible(true);
	chart.setMaxSize(400, 400);
	chart.setLegendSide(Side.RIGHT);
	chart.setLabelLineLength(3);
	chart.setLegendSide(Side.BOTTOM);
	chart.setData(pieChartData);
	BorderPane pane = new BorderPane();
	pane.setStyle("-fx-background-color: #1d1d1d");
	pane.setLeft(table);
	pane.setRight(chart);
	
	return pane;
	  
}
 
开发者ID:naeemkhan12,项目名称:IOTproject,代码行数:46,代码来源:ChartControls.java


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