Example usage for javafx.scene.control TableColumn setCellValueFactory

List of usage examples for javafx.scene.control TableColumn setCellValueFactory

Introduction

In this page you can find the example usage for javafx.scene.control TableColumn setCellValueFactory.

Prototype

public final void setCellValueFactory(Callback<CellDataFeatures<S, T>, ObservableValue<T>> value) 

Source Link

Usage

From source file:com.toyota.carservice.config.config2.java

public static void setModelColumn(TableColumn tb, String a) {
    tb.setCellValueFactory(new PropertyValueFactory(a));
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setWidth(400);/*from w w w . j a va2 s  .  c o  m*/
    stage.setHeight(550);

    table.setEditable(true);

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

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

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

    table.setItems(data);
    table.getColumns().addAll(firstNameCol, lastNameCol, emailCol);

    final VBox vbox = new VBox();
    vbox.setSpacing(5);
    vbox.setPadding(new Insets(10, 0, 0, 10));
    vbox.getChildren().addAll(table);

    ((Group) scene.getRoot()).getChildren().addAll(vbox);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setWidth(400);/*from   w  w w  . j a  va 2 s . c om*/
    stage.setHeight(550);

    table.setEditable(true);

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

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

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

    table.setItems(data);
    table.getColumns().addAll(firstNameCol, lastNameCol, emailCol);

    final Button addButton = new Button("Add");
    addButton.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent e) {
            data.add(new Person("new", "new", "new"));
        }
    });

    final VBox vbox = new VBox();
    vbox.setSpacing(5);
    vbox.setPadding(new Insets(10, 0, 0, 10));
    vbox.getChildren().addAll(table, addButton);

    ((Group) scene.getRoot()).getChildren().addAll(vbox);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setWidth(450);/*from w w w  .  j a  va 2 s .co  m*/
    stage.setHeight(550);

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

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

    table.setItems(data);
    table.getColumns().addAll(firstNameCol, lastNameCol);

    firstNameCol.setSortType(TableColumn.SortType.DESCENDING);
    lastNameCol.setSortable(false);

    final VBox vbox = new VBox();
    vbox.setSpacing(5);
    vbox.setPadding(new Insets(10, 0, 0, 10));
    vbox.getChildren().addAll(table);

    ((Group) scene.getRoot()).getChildren().addAll(vbox);

    stage.setScene(scene);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setWidth(450);/*  w ww. j ava  2 s  .  co  m*/
    stage.setHeight(550);

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

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

    table.setItems(data);
    table.getColumns().addAll(firstNameCol, lastNameCol);

    final Button addButton = new Button("Add");
    addButton.setOnAction((ActionEvent e) -> {
        data.add(new Person("Z", "X"));
    });

    hb.getChildren().addAll(addButton);
    hb.setSpacing(3);

    final VBox vbox = new VBox();
    vbox.setSpacing(5);
    vbox.setPadding(new Insets(10, 0, 0, 10));
    vbox.getChildren().addAll(table, hb);

    ((Group) scene.getRoot()).getChildren().addAll(vbox);

    stage.setScene(scene);
    stage.show();
}

From source file:br.com.ajaio.midas.desktop.controller.DashBoardController.java

private void populaTabelaConta() {
    contas = contaService.findByUsuario(usuarioLogado);
    ArrayList<Conta> contasDM = new ArrayList<Conta>();
    for (ContaEntity c : contas) {
        Conta conta = new Conta(c);
        contasDM.add(conta);//from  w ww  .  ja  v  a 2  s . c om
    }
    final ObservableList<Conta> data = FXCollections.observableArrayList(contasDM);
    TableColumn<Conta, String> contaNomeColumn = new TableColumn<Conta, String>();
    contaNomeColumn.setCellValueFactory(new PropertyValueFactory<Conta, String>("nome"));
    tbContas.setItems(data);
    tbContas.getColumns().addAll(contaNomeColumn);
}

From source file:Main.java

@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setWidth(450);// w ww  .  ja v a 2s.c o  m
    stage.setHeight(550);

    table.setEditable(true);

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

    firstNameCol.setCellFactory(TextFieldTableCell.<Person>forTableColumn());
    firstNameCol.setOnEditCommit((CellEditEvent<Person, String> t) -> {
        ((Person) t.getTableView().getItems().get(t.getTablePosition().getRow())).setFirstName(t.getNewValue());
    });

    TableColumn<Person, String> lastNameCol = new TableColumn<>("Last Name");
    lastNameCol.setMinWidth(100);
    lastNameCol.setCellValueFactory(new PropertyValueFactory<>("lastName"));
    lastNameCol.setCellFactory(TextFieldTableCell.<Person>forTableColumn());
    lastNameCol.setOnEditCommit((CellEditEvent<Person, String> t) -> {
        ((Person) t.getTableView().getItems().get(t.getTablePosition().getRow())).setLastName(t.getNewValue());
    });
    table.setItems(data);
    table.getColumns().addAll(firstNameCol, lastNameCol);

    final VBox vbox = new VBox();
    vbox.setSpacing(5);
    vbox.setPadding(new Insets(10, 0, 0, 10));
    vbox.getChildren().addAll(table);

    ((Group) scene.getRoot()).getChildren().addAll(vbox);

    stage.setScene(scene);
    stage.show();
}

From source file:br.com.ajaio.midas.desktop.controller.ContaCrudFXMLController.java

/**
 * Initializes the controller class.//w w  w. j  a  v a 2  s  . c o m
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    TableColumn nomeBancoCol = new TableColumn("Banco");
    nomeBancoCol.setMinWidth(200);
    nomeBancoCol.setCellValueFactory(new PropertyValueFactory<Conta, String>("nomeBanco"));

    TableColumn agenciaCol = new TableColumn("Agncia");
    agenciaCol.setMinWidth(200);
    agenciaCol.setCellValueFactory(new PropertyValueFactory<Conta, String>("agencia"));

    TableColumn contaCol = new TableColumn("Conta");
    contaCol.setMinWidth(200);
    contaCol.setCellValueFactory(new PropertyValueFactory<Conta, String>("conta"));

    TableColumn saldoCol = new TableColumn("Saldo Atual");
    saldoCol.setMinWidth(200);
    saldoCol.setCellValueFactory(new PropertyValueFactory<Conta, String>("saldoAtual"));

    TableColumn editar = new TableColumn("Editar");

    TableColumn apagar = new TableColumn("Apagar");

    tbContas.getColumns().addAll(nomeBancoCol, agenciaCol, contaCol, saldoCol, editar, apagar);

    context = new ClassPathXmlApplicationContext("application-context.xml");
}

From source file:br.com.ajaio.midas.desktop.controller.BancoCrudFXMLController.java

/**
 * Initializes the controller class.//from  w w w. j av a 2 s.c o m
 */
@Override
public void initialize(URL url, ResourceBundle rb) {
    TableColumn nomeCol = new TableColumn("Nome Banco");
    nomeCol.setMinWidth(200);
    nomeCol.setCellValueFactory(new PropertyValueFactory<Banco, String>("nome"));

    TableColumn numeroCol = new TableColumn("Nmero Banco");
    numeroCol.setMinWidth(150);
    numeroCol.setCellValueFactory(new PropertyValueFactory<Banco, String>("numeroBanco"));

    TableColumn editar = new TableColumn("Editar");

    TableColumn apagar = new TableColumn("Apagar");

    tbBancos.getColumns().addAll(nomeCol, numeroCol, editar, apagar);

    context = new ClassPathXmlApplicationContext("application-context.xml");
}

From source file:com.bdb.weather.display.day.ItemRenderer.java

public WindDirPane() {
    setPrefSize(300, 300);//from  w  ww .j a  va2 s. c o m
    JFreeChart chart = ChartFactory.createPolarChart(null, null, false, true, false);

    ChartFactory.getChartTheme().apply(chart);

    plot = (PolarPlot) chart.getPlot();

    ItemRenderer renderer = new ItemRenderer();
    XYToolTipGenerator ttg = (XYDataset dataset, int series, int item) -> {
        double time = dataset.getXValue(series, item);
        long millis = Math.round(time);
        return "" + millis;
    };
    renderer.setBaseToolTipGenerator(ttg);
    plot.setRenderer(renderer);

    ((NumberAxis) plot.getAxis()).setRange(-240.0, 60.0 * 24);
    ((NumberAxis) plot.getAxis()).setAutoRange(false);
    ((NumberAxis) plot.getAxis()).setTickUnit(new NumberTickUnit(240.0, new DecimalFormat("00")) {
        @Override
        public String valueToString(double number) {
            if (number < 0.0 || (int) number % 240 != 0)
                return "";
            else
                return super.valueToString(number / 60.0);
        }
    });

    ChartViewer chartViewer = new ChartViewer(chart);
    this.setTabContents(chartViewer, table);

    plot.setDataset(new XYSeriesCollection(windDirSeries));

    TableColumn<HistoricalRecord, String> column = new TableColumn<>("Time");
    column.setCellValueFactory((rec) -> new ReadOnlyStringWrapper(
            DisplayConstants.formatTime(rec.getValue().getTime().toLocalTime())));
    table.getColumns().add(column);

    column = new TableColumn<>("Direction");
    column.setCellValueFactory(
            (rec) -> new ReadOnlyStringWrapper(rec.getValue().getAvgWind().getDirection().getCompassLabel()));
    table.getColumns().add(column);
}