javafx.scene.control.TableColumn#setMinWidth ( )源码实例Demo

下面列出了javafx.scene.control.TableColumn#setMinWidth ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: marathonv5   文件: TableSample.java
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);
}
 
源代码2 项目: marathonv5   文件: TableScrollSample.java
public TableScrollSample() {
    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);
    ObservableList items = tableView.getItems();
    for (int i = 0; i < 10; i++)
        items.add(new Person("Name" + i, "Last" + i, "Email " + i));
    tableView.getColumns().addAll(firstNameCol, lastNameCol, emailCol);
    getChildren().add(tableView);
}
 
源代码3 项目: phoebus   文件: ArchiveListPane.java
public ArchiveListPane()
{
    archive_list = new TableView<>(FXCollections.observableArrayList(Preferences.archive_urls));

    final TableColumn<ArchiveDataSource, String> arch_col = new TableColumn<>(Messages.ArchiveName);
    arch_col.setCellValueFactory(cell -> new SimpleStringProperty(cell.getValue().getName()));
    arch_col.setMinWidth(0);
    archive_list.getColumns().add(arch_col);

    final MenuItem item_info = new MenuItem(Messages.ArchiveServerInfo, Activator.getIcon("info_obj"));
    item_info.setOnAction(event -> showArchiveInfo());
    ContextMenu menu = new ContextMenu(item_info);
    archive_list.setContextMenu(menu);

    archive_list.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    archive_list.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

    setCenter(archive_list);
}
 
源代码4 项目: phoebus   文件: PVList.java
private void createTableColumns()
{
    final TableColumn<PVInfo, Boolean> conn_col = new TableColumn<>(Messages.PVListTblConnected);
    conn_col.setCellFactory(col -> new ConnectedCell());
    conn_col.setCellValueFactory(cell -> cell.getValue().connected);
    conn_col.setMinWidth(20.0);
    conn_col.setPrefWidth(300.0);
    conn_col.setMaxWidth(500.0);
    table.getColumns().add(conn_col);

    final TableColumn<PVInfo, String> name_col = new TableColumn<>(Messages.PVListTblPVName);
    name_col.setCellValueFactory(cell -> cell.getValue().name);
    table.getColumns().add(name_col);

    final TableColumn<PVInfo, Number> ref_col = new TableColumn<>(Messages.PVListTblReferences);
    ref_col.setCellValueFactory(cell -> cell.getValue().references);
    ref_col.setMaxWidth(500.0);
    table.getColumns().add(ref_col);
}
 
源代码5 项目: SONDY   文件: EventDetectionUI.java
public final void initializeParameterTable(){
    parameterTable.setEditable(true);
    TableColumn keyColumn = new TableColumn("Parameter");
    keyColumn.setMinWidth(Main.columnWidthRIGHT/2-1);
    keyColumn.setCellValueFactory(new PropertyValueFactory<>("name"));
    TableColumn valueColumn = new TableColumn("Value");
    valueColumn.setMinWidth(Main.columnWidthRIGHT/2-1);
    valueColumn.setCellFactory(TextFieldTableCell.forTableColumn());
    valueColumn.setCellValueFactory(new PropertyValueFactory<>("value")); 
    valueColumn.setOnEditCommit(
        new EventHandler<CellEditEvent<Parameter, String>>() {
            @Override
            public void handle(CellEditEvent<Parameter, String> t) {
                ((Parameter) t.getTableView().getItems().get(t.getTablePosition().getRow())).setValue(t.getNewValue());
            }
        }
    );
    parameterTable.getColumns().addAll(keyColumn,valueColumn);
}
 
源代码6 项目: mars-sim   文件: AnimatedTableRow.java
private TableView<Person> createTable() {
    final TableView<Person> table = new TableView<Person>();
    table.setEditable(true);

    TableColumn<Person, String> firstNameCol = new TableColumn<>("First Name");
    firstNameCol.setMinWidth(100);
    firstNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("firstName"));

    TableColumn<Person, String> lastNameCol = new TableColumn<>("Last Name");
    lastNameCol.setMinWidth(100);
    lastNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("lastName"));

    TableColumn<Person, String> emailCol = new TableColumn<>("Email");
    emailCol.setMinWidth(200);
    emailCol.setCellValueFactory(new PropertyValueFactory<Person, String>("email"));

    table.getColumns().addAll(Arrays.asList(firstNameCol, lastNameCol, emailCol));
    return table;
}
 
源代码7 项目: Open-Lowcode   文件: CTimePeriodField.java
@Override
public TableColumn<ObjectTableRow, TimePeriod> getTableColumn(
		PageActionManager pageactionmanager,
		boolean largedisplay,
		int preferedrowheight,
		String actionkeyforupdate) {
	TableColumn<
			ObjectTableRow, TimePeriod> thiscolumn = new TableColumn<ObjectTableRow, TimePeriod>(this.getLabel());
	if (actionkeyforupdate != null) {
		thiscolumn.setEditable(true);
		thiscolumn.setOnEditCommit(new TableColumnOnEditCommit(this));
	} else {
		thiscolumn.setEditable(false);
	}

	int length = 15 * 7;
	if (length > 300)
		length = 300;

	double pixellength = ((new Text(this.label)).getBoundsInLocal().getWidth() + 10) * 1.05;

	int pixellengthi = (int) pixellength;
	thiscolumn.setMinWidth(pixellengthi);
	thiscolumn.setPrefWidth(pixellengthi);
	thiscolumn.setCellValueFactory(new TableCellValueFactory(this));

	thiscolumn.setCellFactory(new TableCellFactory(helper, periodtype));

	return thiscolumn;
}
 
源代码8 项目: pdfsam   文件: LoadingColumn.java
@Override
public TableColumn<SelectionTableRowData, PdfDescriptorLoadingStatus> getTableColumn() {
    TableColumn<SelectionTableRowData, PdfDescriptorLoadingStatus> tableColumn = new TableColumn<>(getColumnTitle());
    tableColumn.setCellFactory(cellFactory());
    tableColumn.setCellValueFactory(cellValueFactory());
    tableColumn.setComparator(null);
    tableColumn.setSortable(false);
    tableColumn.setMaxWidth(26);
    tableColumn.setMinWidth(26);
    return tableColumn;
}
 
源代码9 项目: marathonv5   文件: TaskSample.java
public TaskSample() {
    TableView<DailySales> tableView = new TableView<DailySales>();
    Region veil = new Region();
    veil.setStyle("-fx-background-color: rgba(0, 0, 0, 0.4)");
    ProgressIndicator p = new ProgressIndicator();
    p.setMaxSize(150, 150);
    //Define table columns
    TableColumn idCol = new TableColumn();
    idCol.setText("ID");
    idCol.setCellValueFactory(new PropertyValueFactory("dailySalesId"));
    tableView.getColumns().add(idCol);
    TableColumn qtyCol = new TableColumn();
    qtyCol.setText("Qty");
    qtyCol.setCellValueFactory(new PropertyValueFactory("quantity"));
    tableView.getColumns().add(qtyCol);
    TableColumn dateCol = new TableColumn();
    dateCol.setText("Date");
    dateCol.setCellValueFactory(new PropertyValueFactory("date"));
    dateCol.setMinWidth(240);
    tableView.getColumns().add(dateCol);
    StackPane stack = new StackPane();
    stack.getChildren().addAll(tableView, veil, p);

    // Use binding to be notified whenever the data source chagnes
    Task<ObservableList<DailySales>> task = new GetDailySalesTask();
    p.progressProperty().bind(task.progressProperty());
    veil.visibleProperty().bind(task.runningProperty());
    p.visibleProperty().bind(task.runningProperty());
    tableView.itemsProperty().bind(task.valueProperty());

    getChildren().add(stack);
    new Thread(task).start();
}
 
源代码10 项目: marathonv5   文件: TaskSample.java
public TaskSample() {
    TableView<DailySales> tableView = new TableView<DailySales>();
    Region veil = new Region();
    veil.setStyle("-fx-background-color: rgba(0, 0, 0, 0.4)");
    ProgressIndicator p = new ProgressIndicator();
    p.setMaxSize(150, 150);
    //Define table columns
    TableColumn idCol = new TableColumn();
    idCol.setText("ID");
    idCol.setCellValueFactory(new PropertyValueFactory("dailySalesId"));
    tableView.getColumns().add(idCol);
    TableColumn qtyCol = new TableColumn();
    qtyCol.setText("Qty");
    qtyCol.setCellValueFactory(new PropertyValueFactory("quantity"));
    tableView.getColumns().add(qtyCol);
    TableColumn dateCol = new TableColumn();
    dateCol.setText("Date");
    dateCol.setCellValueFactory(new PropertyValueFactory("date"));
    dateCol.setMinWidth(240);
    tableView.getColumns().add(dateCol);
    StackPane stack = new StackPane();
    stack.getChildren().addAll(tableView, veil, p);

    // Use binding to be notified whenever the data source chagnes
    Task<ObservableList<DailySales>> task = new GetDailySalesTask();
    p.progressProperty().bind(task.progressProperty());
    veil.visibleProperty().bind(task.runningProperty());
    p.visibleProperty().bind(task.runningProperty());
    tableView.itemsProperty().bind(task.valueProperty());

    getChildren().add(stack);
    new Thread(task).start();
}
 
源代码11 项目: SONDY   文件: EventDetectionUI.java
public final void initializeEventTable(){
    eventTable = new TableView<>();
    eventTable.setItems(eventList.observableList);
    UIUtils.setSize(eventTable, Main.columnWidthRIGHT, 247);
    TableColumn textualDescription = new TableColumn("Textual desc.");
    textualDescription.setMinWidth(Main.columnWidthRIGHT/2);
    TableColumn temporalDescription = new TableColumn("Temporal desc.");
    temporalDescription.setMinWidth(Main.columnWidthRIGHT/2-1);
    textualDescription.setCellValueFactory(new PropertyValueFactory<>("textualDescription"));
    temporalDescription.setCellValueFactory(new PropertyValueFactory<>("temporalDescription"));
    EventTableContextMenu tableCellFactory = new EventTableContextMenu(createSelectedEventHandler(), new ContextMenu());
    textualDescription.setCellFactory(tableCellFactory);
    eventTable.getColumns().addAll(textualDescription,temporalDescription);
}
 
源代码12 项目: marathonv5   文件: TableSample1.java
public TableSample1() {
    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]"),
            new Person("Ethan", "Williams", "[email protected]"),
            new Person("Emma", "Jones", "[email protected]"), new Person("Michael", "Brown", "[email protected]"),
            new Person("Ethan", "Williams", "[email protected]"),
            new Person("Emma", "Jones", "[email protected]"), new Person("Michael", "Brown", "[email protected]"),
            new Person("Ethan", "Williams", "[email protected]"),
            new Person("Emma", "Jones", "[email protected]"), new Person("Michael", "Brown", "[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);
}
 
源代码13 项目: SONDY   文件: LogUI.java
public LogUI(){
    // Initializing the main grid
    logGrid = new GridPane();
    logGrid.setPadding(new Insets(5, 5, 5, 5));
    
    // Adding separators
    logGrid.add(new Text("Log"),0,0);
    logGrid.add(new Separator(),0,1);
    
    // App status monitoring
    memoryLabel = new Label();
    UIUtils.setSize(memoryLabel, Main.columnWidthLEFT, 24);
    progressBar = new ProgressBar(0);
    UIUtils.setSize(progressBar, Main.columnWidthRIGHT, 12);
    HBox appStatusBox = new HBox(5);
    appStatusBox.setAlignment(Pos.CENTER);
    appStatusBox.getChildren().addAll(memoryLabel,progressBar);
    logGrid.add(appStatusBox,0,2);
    
    // Creating the log table
    logTable = new TableView<>();
    UIUtils.setSize(logTable,Main.windowWidth-10,150);
    TableColumn logTimeColumn = new TableColumn("Time");
    logTimeColumn.setMinWidth(90);
    logTimeColumn.setMaxWidth(90);
    TableColumn logDetailsColumn = new TableColumn("Log");
    logDetailsColumn.setMinWidth(Main.windowWidth-85);
    logTimeColumn.setCellValueFactory(new PropertyValueFactory<>("time"));
    logDetailsColumn.setCellValueFactory(new PropertyValueFactory<>("info"));
    logTable.getColumns().addAll(logTimeColumn,logDetailsColumn);
    logGrid.add(logTable,0,3);
}
 
源代码14 项目: Open-Lowcode   文件: CMultipleChoiceField.java
@Override
public TableColumn<ObjectTableRow, ?> getTableColumn(
		PageActionManager pageactionmanager,
		boolean largedisplay,
		int preferedrowheight,
		String actionkeyforupdate) {
	TableColumn<ObjectTableRow, String> thiscolumn = new TableColumn<ObjectTableRow, String>(this.getLabel());
	thiscolumn.setEditable(false);
	int length = (this.maxcharlength * 7);
	if (length > 300)
		length = 300;
	if (this.prefereddisplayintable >= 0) {
		length = this.prefereddisplayintable * 7;

	}
	logger.fine(" --**-- length for field" + this.getLabel() + " maxcharlength:" + maxcharlength
			+ " pref display in table " + this.prefereddisplayintable + " final length = " + length);

	thiscolumn.setMinWidth(length);
	thiscolumn.setPrefWidth(length);
	CMultipleChoiceField thischoicefield = this;
	thiscolumn.setCellValueFactory(
			new Callback<TableColumn.CellDataFeatures<ObjectTableRow, String>, ObservableValue<String>>() {

				@SuppressWarnings("unchecked")
				@Override
				public ObservableValue<String> call(
						javafx.scene.control.TableColumn.CellDataFeatures<ObjectTableRow, String> p) {

					ObjectDataElt line = p.getValue().getObject();
					String fieldname = thischoicefield.getFieldname();
					if (line == null)
						return new SimpleStringProperty("");
					SimpleDataElt lineelement = line.lookupEltByName(fieldname);
					if (lineelement == null) {

						return new SimpleStringProperty("Field Not found !" + fieldname);
					}
					if (!(lineelement instanceof MultipleChoiceDataElt))
						return new SimpleStringProperty("Invalid type " + lineelement.getType());

					return new SimpleStringProperty(thischoicefield
							.displayMultiValue((MultipleChoiceDataElt<CChoiceFieldValue>) lineelement));
				}

			});
	return thiscolumn;
}
 
源代码15 项目: Open-Lowcode   文件: CIntegerField.java
@Override
public TableColumn<ObjectTableRow, Integer> getTableColumn(
		PageActionManager pageactionmanager,
		boolean largedisplay,
		int preferedrowheight,
		String actionkeyforupdate) {
	TableColumn<ObjectTableRow, Integer> thiscolumn = new TableColumn<ObjectTableRow, Integer>(this.getLabel());
	if (actionkeyforupdate != null) {
		thiscolumn.setEditable(true);
	} else {
		thiscolumn.setEditable(false);
	}
	int length = 110;
	thiscolumn.setMinWidth(length);
	CIntegerField thisintegerfield = this;

	thiscolumn.setCellFactory(column -> {
		return new TableCell<ObjectTableRow, Integer>() {
			@Override
			protected void updateItem(Integer integer, boolean empty) {
				super.updateItem(integer, empty);
				if (integer == null || empty) {
					setText("0");

				} else {
					setText(integer.toString());

				}

			}
		};
	});

	thiscolumn.setCellValueFactory(
			new Callback<CellDataFeatures<ObjectTableRow, Integer>, ObservableValue<Integer>>() {

				@Override
				public ObservableValue<Integer> call(CellDataFeatures<ObjectTableRow, Integer> p) {
					try {
						ObjectTableRow line = p.getValue();
						String fieldname = thisintegerfield.getFieldname();
						SimpleDataElt lineelement = line.getFieldDataEltClone(fieldname);

						if (lineelement == null)
							return new SimpleObjectProperty<Integer>(null);
						if (!(lineelement instanceof IntegerDataElt))
							return new SimpleObjectProperty<Integer>(null);
						IntegerDataElt linedataelt = (IntegerDataElt) lineelement;
						return new SimpleObjectProperty<Integer>(linedataelt.getPayload());
					} catch (RuntimeException e) {
						ExceptionLogger.setInLogs(e, logger);
						return null;
					}
				}

			});

	return thiscolumn;
}
 
源代码16 项目: marathonv5   文件: ServiceSample.java
public ServiceSample() {

        VBox vbox = new VBox(5);
        vbox.setPadding(new Insets(12));
        TableView tableView = new TableView();
        Button button = new Button("Refresh");
        button.setOnAction(new EventHandler<ActionEvent>() {

            public void handle(ActionEvent t) {
                service.restart();
            }
        });
        vbox.getChildren().addAll(tableView, button);

        Region veil = new Region();
        veil.setStyle("-fx-background-color: rgba(0, 0, 0, 0.4)");
        ProgressIndicator p = new ProgressIndicator();
        p.setMaxSize(150, 150);

        //Define table columns
        TableColumn idCol = new TableColumn();
        idCol.setText("ID");
        idCol.setCellValueFactory(new PropertyValueFactory("dailySalesId"));
        tableView.getColumns().add(idCol);
        TableColumn qtyCol = new TableColumn();
        qtyCol.setText("Qty");
        qtyCol.setCellValueFactory(new PropertyValueFactory("quantity"));
        tableView.getColumns().add(qtyCol);
        TableColumn dateCol = new TableColumn();
        dateCol.setText("Date");
        dateCol.setCellValueFactory(new PropertyValueFactory("date"));
        dateCol.setMinWidth(240);
        tableView.getColumns().add(dateCol);


        p.progressProperty().bind(service.progressProperty());
        veil.visibleProperty().bind(service.runningProperty());
        p.visibleProperty().bind(service.runningProperty());
        tableView.itemsProperty().bind(service.valueProperty());

        StackPane stack = new StackPane();
        stack.getChildren().addAll(vbox, veil, p);

        getChildren().add(stack);
        service.start();
    }
 
源代码17 项目: marathonv5   文件: ServiceSample.java
public ServiceSample() {

        VBox vbox = new VBox(5);
        vbox.setPadding(new Insets(12));
        TableView tableView = new TableView();
        Button button = new Button("Refresh");
        button.setOnAction(new EventHandler<ActionEvent>() {

            public void handle(ActionEvent t) {
                service.restart();
            }
        });
        vbox.getChildren().addAll(tableView, button);

        Region veil = new Region();
        veil.setStyle("-fx-background-color: rgba(0, 0, 0, 0.4)");
        ProgressIndicator p = new ProgressIndicator();
        p.setMaxSize(150, 150);

        //Define table columns
        TableColumn idCol = new TableColumn();
        idCol.setText("ID");
        idCol.setCellValueFactory(new PropertyValueFactory("dailySalesId"));
        tableView.getColumns().add(idCol);
        TableColumn qtyCol = new TableColumn();
        qtyCol.setText("Qty");
        qtyCol.setCellValueFactory(new PropertyValueFactory("quantity"));
        tableView.getColumns().add(qtyCol);
        TableColumn dateCol = new TableColumn();
        dateCol.setText("Date");
        dateCol.setCellValueFactory(new PropertyValueFactory("date"));
        dateCol.setMinWidth(240);
        tableView.getColumns().add(dateCol);


        p.progressProperty().bind(service.progressProperty());
        veil.visibleProperty().bind(service.runningProperty());
        p.visibleProperty().bind(service.runningProperty());
        tableView.itemsProperty().bind(service.valueProperty());

        StackPane stack = new StackPane();
        stack.getChildren().addAll(vbox, veil, p);

        getChildren().add(stack);
        service.start();
    }
 
源代码18 项目: phoebus   文件: OpenAbout.java
@Override
public Void call()
{
    dialog = new Alert(AlertType.INFORMATION);
    dialog.setTitle(Messages.HelpAboutTitle);
    dialog.setHeaderText(Messages.HelpAboutHdr);

    // Table with Name, Value columns
    final ObservableList<List<String>> infos = FXCollections.observableArrayList();
    // Start with most user-specific to most generic: User location, install, JDK, ...
    // Note that OpenFileBrowserCell is hard-coded to add a "..." button for the first few rows.
    infos.add(Arrays.asList(Messages.HelpAboutUser, Locations.user().toString()));
    infos.add(Arrays.asList(Messages.HelpAboutInst, Locations.install().toString()));
    infos.add(Arrays.asList(Messages.HelpAboutUserDir, System.getProperty("user.dir")));
    infos.add(Arrays.asList(Messages.HelpJavaHome, System.getProperty("java.home")));
    infos.add(Arrays.asList(Messages.AppVersionHeader, Messages.AppVersion));
    infos.add(Arrays.asList(Messages.HelpAboutJava, System.getProperty("java.specification.vendor") + " " + System.getProperty("java.runtime.version")));
    infos.add(Arrays.asList(Messages.HelpAboutJfx, System.getProperty("javafx.runtime.version")));
    infos.add(Arrays.asList(Messages.HelpAboutPID, Long.toString(ProcessHandle.current().pid())));

    // Display in TableView
    final TableView<List<String>> info_table = new TableView<>(infos);
    info_table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    info_table.setPrefHeight(290.0);

    final TableColumn<List<String>, String> name_col = new TableColumn<>(Messages.HelpAboutColName);
    name_col.setCellValueFactory(cell -> new SimpleStringProperty(cell.getValue().get(0)));
    info_table.getColumns().add(name_col);

    final TableColumn<List<String>, String> value_col = new TableColumn<>(Messages.HelpAboutColValue);
    value_col.setCellValueFactory(cell -> new SimpleStringProperty(cell.getValue().get(1)));
    value_col.setCellFactory(col -> new ReadOnlyTextCell<>());
    info_table.getColumns().add(value_col);

    final TableColumn<List<String>, String> link_col = new TableColumn<>();
    link_col.setMinWidth(50);
    link_col.setMaxWidth(50);
    link_col.setCellValueFactory(cell -> new SimpleStringProperty(cell.getValue().get(1)));
    link_col.setCellFactory(col ->  new OpenFileBrowserCell());
    info_table.getColumns().add(link_col);

    dialog.getDialogPane().setContent(info_table);

    // Info for expandable "Show Details" section
    dialog.getDialogPane().setExpandableContent(createDetailSection());

    dialog.setResizable(true);
    dialog.getDialogPane().setPrefWidth(800);
    DialogHelper.positionDialog(dialog, DockPane.getActiveDockPane(), -400, -300);

    dialog.showAndWait();
    // Indicate that dialog is closed; allow GC
    dialog = null;

    return null;
}
 
源代码19 项目: mars-sim   文件: TableViewCombo.java
public void init() {
        TableColumn<SettlementBase, String> nameCol = new TableColumn<>(headers[0]);
        nameCol.setCellValueFactory(cellData -> cellData.getValue().nameProperty());
        //nameCol.setCellFactory(TextFieldTableCell.forTableColumn());
        nameCol = setCellFactory(nameCol);
        nameCol.setMinWidth(150);

        templateCol = new TableColumn<>(headers[1]);
        templateCol.setCellValueFactory(cellData -> cellData.getValue().templateProperty());
        templateCol.setCellFactory(ComboBoxTableCell.forTableColumn(
        		templates.get(0).getTemplateName(),
        		templates.get(1).getTemplateName(),
        		templates.get(2).getTemplateName(),
        		templates.get(3).getTemplateName(),
        		templates.get(4).getTemplateName(),
        		templates.get(5).getTemplateName()));
        templateCol.setMinWidth(250);

        settlerCol = new TableColumn<>(headers[2]);
        settlerCol.setCellValueFactory(cellData -> cellData.getValue().settlerProperty());
        //settlerCol.setCellFactory(TextFieldTableCell.forTableColumn());
        settlerCol = setCellFactory(settlerCol);
        settlerCol.setMinWidth(50);

        //private ValidationSupport validationSupport = new ValidationSupport();
		//validationSupport.registerValidator(TextField, Validator.createEmptyValidator("Text is required"));

        botCol = new TableColumn<>(headers[3]);
        botCol.setCellValueFactory(cellData -> cellData.getValue().botProperty());
        //botCol.setCellFactory(TextFieldTableCell.forTableColumn());
        botCol = setCellFactory(botCol);
        botCol.setMinWidth(50);

        TableColumn<SettlementBase, String> sponsorCol = new TableColumn<>(headers[4]);
        sponsorCol.setCellValueFactory(cellData -> cellData.getValue().sponsorProperty());
        sponsorCol.setCellFactory(ComboBoxTableCell.forTableColumn(
        		SPONSORS[0].toString(),
        		SPONSORS[1].toString(),
        		SPONSORS[2].toString(),
        		SPONSORS[3].toString(),
        		SPONSORS[4].toString(),
        		SPONSORS[5].toString(),
        		SPONSORS[6].toString(),
        		SPONSORS[7].toString()
//        		SPONSORS[8].toString()    		
        		));
        sponsorCol.setMinWidth(300);


        latCol = new TableColumn<>(headers[5]);
        latCol.setCellValueFactory(cellData -> cellData.getValue().latitudeProperty());
        //latCol.setCellFactory(TextFieldTableCell.forTableColumn());
        latCol = setCellFactory(latCol);
        latCol.setMinWidth(70);


        longCol = new TableColumn<>(headers[6]);
        longCol.setCellValueFactory(cellData -> cellData.getValue().longitudeProperty());
        //longCol.setCellFactory(TextFieldTableCell.forTableColumn());
        longCol = setCellFactory(longCol);
        longCol.setMinWidth(70);

        table_view.getColumns().addAll(nameCol, templateCol ,settlerCol ,botCol ,sponsorCol ,latCol, longCol);
        table_view.getItems().addAll(generateDataInMap());

		// attach a list change listener to allData
		addListChangeListener();
    }
 
源代码20 项目: mars-sim   文件: SettlementTableView.java
public TableView createGUI() {

		for (int x = 0; x < NUM_COLUMNS; x++) {
			TableColumn<Map, String> col = new TableColumn<>(headers[x]);
			col.setCellValueFactory(new MapValueFactory(x));
			col.setMinWidth(col_widths[x]);
			cols.add(col);
		}

        table_view = new TableView<>(generateDataInMap());
        table_view.setEditable(true);
        table_view.getSelectionModel().setCellSelectionEnabled(true);
        table_view.getColumns().setAll(cols.get(0), cols.get(1), cols.get(2), 
        		cols.get(3), cols.get(4), cols.get(5), cols.get(6));

        Callback<TableColumn<Map, String>, TableCell<Map, String>>
            cellFactoryForMap = new Callback<TableColumn<Map, String>, TableCell<Map, String>>() {
                    @Override
                    public TableCell call(TableColumn p) {
                        return new TextFieldTableCell(new StringConverter() {
                            @Override
                            public String toString(Object o) {
                            	//updateSettlementInfo();
                            	//System.out.println("o.toString() is "+ o.toString());                    	
                        		//validationSupport.registerValidator((TextField) o, Validator.createEmptyValidator("Text is required"));
                            	return o.toString();
                            }
                            @Override
                            public Object fromString(String s) {
                            	//updateSettlementInfo();
                            	//System.out.println("string() is "+ s);
                                return s;
                            }                                    
                        });
                    }
        };
        
        for (int x = 0; x < NUM_COLUMNS; x++) {
			cols.get(x).setCellFactory(cellFactoryForMap);
		}
        
        return table_view;
    }