thanks bro, I wasted my entire evening and finally found your video. It was nowhere mentioned that we have to refer to controller.java in fxml file. Finally you mentioned it.
This video helped out a ton. I am trying to implement the MVC architecture, but didn't quite understand how to have the parent M, V, C components while also supporting modularity and scalability to the application later on.
I was trying to figure out how to make a dashboard type application without having to switch the scene every single time since that can be taxing, and switch child elements for the parts of the page that do change.
Well I finally figured out my problem, but how come you don't have to add an "opens" directive for the new controller in the module-info.java file that you don't even seem to have?
Hi mate can you help please, im stuck on table view , i couldnt make the table-cell height get resized to fit all text within ! I will be so grateful thanks a lot
To adjust the row height of a TableView in JavaFX, you can use the setRowFactory method on the TableView object and specify a Callback that returns a TableRow object. You can then override the updateItem method of the TableRow class to set the row height based on the content of the cells. Code example: tableView.setRowFactory(tv -> { TableRow row = new TableRow(); row.heightProperty().addListener((obs, oldHeight, newHeight) -> { if (newHeight.doubleValue() > oldHeight.doubleValue()) { tableView.setPrefHeight(tableView.getHeight() + (newHeight.doubleValue() - oldHeight.doubleValue())); } else { tableView.setPrefHeight(tableView.getHeight() - (oldHeight.doubleValue() - newHeight.doubleValue())); } }); return row; }); To adjust the row height of a TableView in JavaFX, you can use the setRowFactory method on the TableView object and specify a Callback that returns a TableRow object. You can then override the updateItem method of the TableRow class to set the row height based on the content of the cells. Here is an example of how you can do this: Copy code tableView.setRowFactory(tv -> { TableRow row = new TableRow(); row.heightProperty().addListener((obs, oldHeight, newHeight) -> { if (newHeight.doubleValue() > oldHeight.doubleValue()) { tableView.setPrefHeight(tableView.getHeight() + (newHeight.doubleValue() - oldHeight.doubleValue())); } else { tableView.setPrefHeight(tableView.getHeight() - (oldHeight.doubleValue() - newHeight.doubleValue())); } }); return row; }); This code will cause the height of the TableRow to adjust based on the content of the cells. The TableView will also automatically adjust its own height to accommodate the changes in row height. (I have not personally ested if this actually wokrs, but it seems promising) Alternatively, you can use a VBox layout inside the cells to wrap the text and cause the cell to grow with the text.
@@Randomcode_0 thanks mate i realy appreciate your help and im sorry for not replying its been a month since you posted the answer ,but since then i didn't code i was busy in my job (a civil engineer 😢😢), and today i tried this solution but it didn't work, but i found another solution on 'stackoverflow' its as you mentioned lastly (Alternatively, you can use a VBox layout inside the cells to wrap the text and cause the cell to grow with the text.) but they used 'textFlow' instead of 'VBox' this did work well for me (i tried to use a 'VBox' instead but it didn't work, again thanks a looooooot man i realy appreciate your help , and this is the code i used : blocIntituleCol.setCellFactory(column -> { return new TableCell() { @Override protected void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (item == null || empty) { setText(null); setStyle(""); } else { TextFlow textFlow = new TextFlow(); textFlow.setPrefHeight(Region.USE_COMPUTED_SIZE); textFlow.getChildren().add(new Text(item)); setContentDisplay(ContentDisplay.GRAPHIC_ONLY); textFlow.maxWidthProperty().bind(getTableColumn().widthProperty().subtract(6)); setGraphic(new Group(textFlow)); } } }; }); solution link : stackoverflow.com/questions/42855724/textflow-inside-tablecell-not-correct-cell-height
@Random code thank you so much another thing i want to add to the previous solution : when you delete a row from the table (by deleting it from observableList) the cells of that row will be deleted except of the modified cell (wich contain the textFlow) will still appear in the table, so you have to use "tableView.refresh()" ; and the same thing when adding an element to table .
Alright, this is very helpful. I just need to find out how i can do this but instead of using tabs, im faking tabs with button (for beautiful vertical left navigation look)
@@abdelhakbekheitia6210 well, my project now has horizontal text with icons, on the left, and hover and focus and selected whatever, makes text and icon change color, i finally hit my goal with that 2-3 days after (a month ago)
@@shoyur thats great 👍 Unlike me i get bored so fast I hate that not all the css properties are available in javaFx For no im stuck on table view , i couldnt make the table-cell height get resized to fit all text within If you have any idea 💡 i will be so grateful
Finally a video that does the job, that oracle tutorial nor stack overflow couldn't. Thanks!
Glad our video was helpful where others weren't. Thanks!
thanks bro, I wasted my entire evening and finally found your video. It was nowhere mentioned that we have to refer to controller.java in fxml file. Finally you mentioned it.
Glad to hear it! It’s always the small things that make the biggest difference.
This video helped out a ton. I am trying to implement the MVC architecture, but didn't quite understand how to have the parent M, V, C components while also supporting modularity and scalability to the application later on.
I was trying to figure out how to make a dashboard type application without having to switch the scene every single time since that can be taxing, and switch child elements for the parts of the page that do change.
Well I finally figured out my problem, but how come you don't have to add an "opens" directive for the new controller in the module-info.java file that you don't even seem to have?
Hi mate can you help please, im stuck on table view , i couldnt make the table-cell height get resized to fit all text within !
I will be so grateful
thanks a lot
To adjust the row height of a TableView in JavaFX, you can use the setRowFactory method on the TableView object and specify a Callback that returns a TableRow object. You can then override the updateItem method of the TableRow class to set the row height based on the content of the cells.
Code example:
tableView.setRowFactory(tv -> {
TableRow row = new TableRow();
row.heightProperty().addListener((obs, oldHeight, newHeight) -> {
if (newHeight.doubleValue() > oldHeight.doubleValue()) {
tableView.setPrefHeight(tableView.getHeight() + (newHeight.doubleValue() - oldHeight.doubleValue()));
} else {
tableView.setPrefHeight(tableView.getHeight() - (oldHeight.doubleValue() - newHeight.doubleValue()));
}
});
return row;
});
To adjust the row height of a TableView in JavaFX, you can use the setRowFactory method on the TableView object and specify a Callback that returns a TableRow object. You can then override the updateItem method of the TableRow class to set the row height based on the content of the cells.
Here is an example of how you can do this:
Copy code
tableView.setRowFactory(tv -> {
TableRow row = new TableRow();
row.heightProperty().addListener((obs, oldHeight, newHeight) -> {
if (newHeight.doubleValue() > oldHeight.doubleValue()) {
tableView.setPrefHeight(tableView.getHeight() + (newHeight.doubleValue() - oldHeight.doubleValue()));
} else {
tableView.setPrefHeight(tableView.getHeight() - (oldHeight.doubleValue() - newHeight.doubleValue()));
}
});
return row;
});
This code will cause the height of the TableRow to adjust based on the content of the cells. The TableView will also automatically adjust its own height to accommodate the changes in row height. (I have not personally ested if this actually wokrs, but it seems promising)
Alternatively, you can use a VBox layout inside the cells to wrap the text and cause the cell to grow with the text.
@@Randomcode_0 thanks mate i realy appreciate your help and im sorry for not replying
its been a month since you posted the answer ,but since then i didn't code i was busy in my job (a civil engineer 😢😢), and today i tried this solution but it didn't work, but i found another solution on 'stackoverflow' its as you mentioned lastly (Alternatively, you can use a VBox layout inside the cells to wrap the text and cause the cell to grow with the text.) but they used 'textFlow' instead of 'VBox' this did work well for me (i tried to use a 'VBox' instead but it didn't work, again thanks a looooooot man i realy appreciate your help , and this is the code i used :
blocIntituleCol.setCellFactory(column -> {
return new TableCell() {
@Override
protected void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (item == null || empty) {
setText(null);
setStyle("");
} else {
TextFlow textFlow = new TextFlow();
textFlow.setPrefHeight(Region.USE_COMPUTED_SIZE);
textFlow.getChildren().add(new Text(item));
setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
textFlow.maxWidthProperty().bind(getTableColumn().widthProperty().subtract(6));
setGraphic(new Group(textFlow));
}
}
};
});
solution link :
stackoverflow.com/questions/42855724/textflow-inside-tablecell-not-correct-cell-height
Don't worry about me :) I'm just glad to hear you found a solution and thank you so much for sharing your learning and solution!
@Random code thank you so much
another thing i want to add to the previous solution :
when you delete a row from the table (by deleting it from observableList) the cells of that row will be deleted except of the modified cell (wich contain the textFlow) will still appear in the table, so you have to use "tableView.refresh()" ;
and the same thing when adding an element to table .
Alright, this is very helpful.
I just need to find out how i can do this but instead of using tabs, im faking tabs with button (for beautiful vertical left navigation look)
that's what I was thinking to do cant we use tabs in vertical left navigations ?
@@abdelhakbekheitia6210 well, my project now has horizontal text with icons, on the left, and hover and focus and selected whatever, makes text and icon change color, i finally hit my goal with that 2-3 days after (a month ago)
@@abdelhakbekheitia6210 just made a 10sec video of it ruclips.net/video/lLSHhKB4jWY/видео.html
@@shoyur thats great 👍
Unlike me i get bored so fast
I hate that not all the css properties are available in javaFx
For no im stuck on table view , i couldnt make the table-cell height get resized to fit all text within
If you have any idea 💡 i will be so grateful
thanks a lot man I really appreciate that
Glad I could help
What is wrong with your voice? cant hear properly