0
   TableColumn candyName = new TableColumn("Candy Name");
    candyName.setMinWidth(100);
    candyName.setCellValueFactory(
            new PropertyValueFactory<Candy, String>("candyName"));

    TableColumn candyBrand = new TableColumn("Candy Brand");
    candyBrand.setMinWidth(100);
    candyBrand.setCellValueFactory(
            new PropertyValueFactory<Candy, String>("candyBrand"));

    TableColumn candyDescription = new TableColumn("Candy Description");
    candyDescription.setMinWidth(200);
    candyDescription.setCellValueFactory(
            new PropertyValueFactory<Candy, String>("candyDescription"));

The last column, candyDescription, doesn't show up when I run the code, but the other two do show up. I'm just confused. Anyone have any ideas of what could be wrong?

  • Are you sure your `Candy` class defines a `candyDescription` property? – Zephyr Sep 24 '18 at 00:48
  • Yeah I checked and everything in the Candy class seems to be in proper order – My Code Made Me Suicidal Sep 24 '18 at 01:32
  • Try including a [mcve] in your question. Without one, it is hard for us to guess what might be going wrong. – Zephyr Sep 24 '18 at 02:23
  • Also, are you saying there is no data in the `candyDescription` column or does the column itself not show in the `TableView`? Did you forget to add the column to the `TableView`? Again, post the entire code so we can help. – Zephyr Sep 24 '18 at 02:25

1 Answers1

-1

In the code sample you've added there are no issues, please find working class, which uses your code here >> - will be available for a month, so please find the answer (assumptions about what might be wrong) below.

Please check next things on your side:

  1. You need to add all 3 TableColumns to TableView instance:

    TableView<Candy> tableCandies = new TableView<>();
    tableCandies.getColumns().addAll(candyName, candyBrand, candyDescription);
    
  2. You need to define correctly fields/getters in the Candy class:

    public static class Candy {
    
        private String candyName;
    
        public String getCandyName() {
            return candyName;
        }
    
        // other fields too
    }
    
  3. You need to define size of the stage to be bigger than size of the table - to have possibility to see scrollbars.

marme1ad
  • 1,253
  • 8
  • 8
  • Answers should not require third party links to code. As you said, the link you posted is only available for month, completely removing any chance this answer has any value to future visitors... Please take the [tour] and review the [answer] article. – Zephyr Sep 24 '18 at 04:14
  • @Zephyr, thank you for the links, I've read them actually. I've provided the answer with 3 main assumptions need to pay attention to in this particular case. I've added external link to the code snippet with example, correct, but answer is still self-contained/enclosed without it. There are several discussions around this in the META, e.g. [this one >>](https://meta.stackexchange.com/questions/149890/prevent-posts-with-links-to-jsfiddle-and-no-code), which says: `To be clear, links to jsfiddle and similar services are OK but a question or answer should stand on its own.` – marme1ad Sep 24 '18 at 09:24
  • This is the main point in all the discussions around external code snippet links, so it is sad that you've downvoted my answer for this. This is an off-topic discussion, but I can't move it to the room right now unfortunately. – marme1ad Sep 24 '18 at 09:29
  • 1
    It ended up being a similar problem – My Code Made Me Suicidal Oct 04 '18 at 20:41