JavaFX Vertical scroll bar always visible in VirtualFlow
dandem sai pradeep
saipradeep.dandem at gmail.com
Wed Oct 2 09:10:26 UTC 2024
Hi,
I am encountering an issue with vertical scroll bar visibility when I set
the height of a TableView to some fixed height. The vertical scroll bar is
always visible.
I am trying to give enough space(height) so that the vertical scroll bar is
not visible, but looks like this only works after some considerable
value..(I mean around 14px or 15px). So assuming this might be an issue in
VirtualFlow, I tested it on ListView and TreeView. And as expected, I can
notice the same issue in those controls as well.
In the attached picture, you can clearly see that there is enough space in
viewport, and I am not expecting a vertical scroll bar. The strange part is
that the vertical scroll bar appears with no active implementation, I mean
I cannot move the bar thumb.
[image: EhfxKJZP.png]
*Note that this issue is very specific only if I fix the height of control.*
Things work as usual if the control is resized dynamically.
Another finding is that, *this issue occurs only if the horizontal scroll
bar is also visible*.
*Tested this on latest version of JavaFX (FX23 build 29*
I am trying to raise a ticket in the bug report. but it is not allowing me
to submit.
Can some one of you raise the ticket ?
Below is the demo code:
import javafx.application.Application;import
javafx.beans.property.ReadOnlyObjectWrapper;import
javafx.geometry.Insets;import javafx.scene.Scene;import
javafx.scene.control.*;import javafx.scene.layout.*;import
javafx.stage.Stage;
import java.util.ArrayList;import java.util.List;
public class VerticalScrollBarVisibilityIssueDemo extends Application {
String CSS = "data:text/css,"+
"""
.list-cell:odd {
-fx-background: #AEAEAE;
}
.table-row-cell:odd {
-fx-background: #AEAEAE;
}
""";
@Override
public void start(final Stage stage) throws Exception {
final VBox root = new VBox();
root.setSpacing(10);
root.setPadding(new Insets(10));
final Scene scene = new Scene(root, 500, 350);
scene.getStylesheets().add(CSS);
stage.setScene(scene);
stage.setTitle("Vertical ScrollBar Visibility Issue " +
System.getProperty("javafx.runtime.version"));
stage.show();
loadRoot(root);
}
private void loadRoot(VBox root) {
TableView<List<String>> tableView = new TableView<>();
tableView.setMaxHeight(120);
VBox.setVgrow(tableView,Priority.ALWAYS);
int colCount = 10;
for(int i =0;i<colCount;i++){
final int index = i;
TableColumn<List<String>, String> column = new
TableColumn<>("Option "+i);
column.setCellValueFactory(param -> new
ReadOnlyObjectWrapper<>(param.getValue().get(index)));
tableView.getColumns().add(column);
}
for(int j=0;j<3;j++){
List<String> row = new ArrayList<>();
for(int i =0;i<colCount;i++){
row.add("Row"+j+"-Opt"+i);
}
tableView.getItems().add(row);
}
ListView<String> listView = new ListView<>();
VBox.setVgrow(listView,Priority.ALWAYS);
listView.setMaxWidth(200);
listView.setMaxHeight(92);
listView.getItems().addAll("Option 1 Big Text TestingOption 1
Big Text Testing", "Option 2","Option 3");
TreeView<String> treeView = new TreeView<>();
VBox.setVgrow(treeView,Priority.ALWAYS);
treeView.setMaxWidth(200);
treeView.setMaxHeight(92);
TreeItem<String> rootItem = new TreeItem<>("Root");
TreeItem<String> item1 = new TreeItem<>("Item 1");
TreeItem<String> item1_1 = new TreeItem<>("Item 1_1");
item1.getChildren().add(item1_1);
TreeItem<String> item2 = new TreeItem<>("Item 2 Item 2 Item 2
Item 2 Item 2 ");
TreeItem<String> item3 = new TreeItem<>("Item 3");
rootItem.getChildren().addAll(item1, item2, item3);
treeView.setRoot(rootItem);
treeView.setShowRoot(false);
root.getChildren().addAll(tableView,listView,treeView);
}
}
Regards,
Sai Pradeep Dandem.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20241002/dec48ec8/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: EhfxKJZP.png
Type: image/png
Size: 17226 bytes
Desc: not available
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20241002/dec48ec8/EhfxKJZP-0001.png>
More information about the openjfx-dev
mailing list