Add TextArea to Table Column Cell, Not the header

56 Views Asked by At

I am on a capstone project for school. It is working completely. I am trying to finish up a few touch up items. Basically, You create an account. Add Items to account you want to sell, and view other accounts of items they are selling. Then buy the items. Well I have a "ViewPane" which stores the other accounts in a VBox with some labels for info, then a TableView which has three columns, Item Name, Description, and Item Price. Well I would like to add a TextArea to the Description Column. So that way the text shown is not truncated by the width of the column.

            VBox vbAccount = new VBox(10);
            Label lbName = new Label(accounts.get(pageIndex).getAccountName());
            Account a = accounts.get(pageIndex);
            Label lbItemCount = new Label("Items: " + accounts.get(pageIndex).getItemCount());
            vbAccount.getChildren().addAll(lbName, lbItemCount, tbvAccounts, hbButtons);
            vbAccount.setAlignment(Pos.TOP_CENTER);
            Account current = accounts.get(pageIndex);
            ObservableList<Item> itemList = 
            FXCollections.observableArrayList(current.getItems());
            tbvAccounts.setMaxSize(302, 300);
            tbvAccounts.setItems(itemList);
            TableColumn nameCol = new TableColumn("Item Name");
            nameCol.setMinWidth(100);
            nameCol.setCellValueFactory(
                    new PropertyValueFactory<Item, String>("itemName"));

            TableColumn descriptionCol = new TableColumn("Description");
            descriptionCol.setMinWidth(150);
            descriptionCol.setCellValueFactory(
                    new PropertyValueFactory<Item, String>("description"));
            TextArea taDescription = new TextArea();
            
            TableColumn priceCol = new TableColumn("Item Price");
            priceCol.setMinWidth(100);
            priceCol.setCellValueFactory(
                    new PropertyValueFactory<Item, Double>("itemPrice"));
            tbvAccounts.getColumns().addAll(nameCol, descriptionCol, priceCol);

I have linked the way my Table Columns are created. If anyone has an answer. Please message me, Thank you.

0

There are 0 best solutions below