예제 #1
0
 @SuppressWarnings("unchecked")
 private void initComponents() {
   pane = new AnchorPane();
   pane.setPrefSize(800, 600);
   pane.setStyle(
       "-fx-background-color: linear-gradient(from 0% 0% to 100% 100%, blue 0%, silver 100%);");
   txPesquisa = new TextField();
   DropShadow ds = new DropShadow();
   ds.setSpread(0.5);
   ds.setColor(Color.web("#FF0000"));
   txPesquisa.setEffect(ds);
   txPesquisa.setPromptText("Digite o item para pesquisa");
   txPesquisa.setPrefWidth(200);
   txPesquisa.setFocusTraversable(false);
   tbVitrine = new TableView<ItensProperty>();
   initItens();
   tbVitrine.setItems(listItens);
   tbVitrine.setPrefSize(780, 550);
   columnProduto = new TableColumn<ItensProperty, String>();
   columnProduto.setCellValueFactory(new PropertyValueFactory<ItensProperty, String>("produto"));
   columnProduto.setText("Produto");
   columnPreco = new TableColumn<ItensProperty, Double>();
   columnPreco.setCellValueFactory(new PropertyValueFactory<ItensProperty, Double>("preco"));
   columnPreco.setText("Preço");
   tbVitrine.getColumns().addAll(columnProduto, columnPreco);
   pane.getChildren().addAll(txPesquisa, tbVitrine);
 }
예제 #2
0
  public void addList(GridPane grid) {
    tableView.setEditable(false);

    Callback<TableColumn, TableCell> integerCellFactory =
        new Callback<TableColumn, TableCell>() {
          @Override
          public TableCell call(TableColumn p) {
            MyIntegerTableCell cell = new MyIntegerTableCell();
            cell.addEventFilter(MouseEvent.MOUSE_CLICKED, new MyEventHandler());
            return cell;
          }
        };

    Callback<TableColumn, TableCell> stringCellFactory =
        new Callback<TableColumn, TableCell>() {
          @Override
          public TableCell call(TableColumn p) {
            MyStringTableCell cell = new MyStringTableCell();
            cell.addEventFilter(MouseEvent.MOUSE_CLICKED, new MyEventHandler());
            return cell;
          }
        };

    Callback<TableColumn, TableCell> activeCellFactory =
        new Callback<TableColumn, TableCell>() {
          @Override
          public TableCell call(TableColumn p) {
            MyStringTableCell cell = new MyStringTableCell();
            cell.addEventFilter(MouseEvent.MOUSE_CLICKED, new MyEventHandler());
            return cell;
          }
        };

    TableColumn colId = new TableColumn("ID");
    colId.setCellValueFactory(new PropertyValueFactory<Record, String>("id"));
    colId.setCellFactory(integerCellFactory);
    colId.setPrefWidth(30);

    TableColumn colName = new TableColumn("Name");
    colName.setCellValueFactory(new PropertyValueFactory<Record, String>("name"));
    colName.setCellFactory(stringCellFactory);
    colName.setPrefWidth(140);

    TableColumn colBoardWidth = new TableColumn("Width");
    colBoardWidth.setCellValueFactory(new PropertyValueFactory<Record, String>("BoardWidth"));
    colBoardWidth.setCellFactory(integerCellFactory);
    colBoardWidth.setPrefWidth(75);

    TableColumn colBoardHeight = new TableColumn("Height");
    colBoardHeight.setCellValueFactory(new PropertyValueFactory<Record, String>("BoardHeight"));
    colBoardHeight.setCellFactory(integerCellFactory);
    colBoardHeight.setPrefWidth(75);

    TableColumn colActive = new TableColumn("Acitve");
    colActive.setCellValueFactory(new PropertyValueFactory<Record, String>("Active"));
    colActive.setCellFactory(activeCellFactory);
    colActive.setPrefWidth(70);

    tableView.setItems(recordList);
    tableView.getColumns().addAll(colId, colName, colBoardWidth, colBoardHeight, colActive);
    tableView.setPrefSize(400, 400);
    grid.add(tableView, 0, 0);
  }