當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。