Fix #5280: 修复部分列表页面出现横向滚动条的问题 (#5284)

This commit is contained in:
Glavo
2026-01-27 20:40:07 +08:00
committed by GitHub
parent 79a1c3af8a
commit d2ae41c9ae
4 changed files with 28 additions and 7 deletions

View File

@@ -433,6 +433,20 @@ public final class FXUtils {
return pane;
}
public static void limitCellWidth(ListView<?> listView, ListCell<?> cell) {
ReadOnlyDoubleProperty widthProperty;
if (listView.lookup(".clipped-container") instanceof Region clippedContainer) {
widthProperty = clippedContainer.widthProperty();
} else {
widthProperty = listView.widthProperty();
}
cell.maxWidthProperty().bind(widthProperty);
cell.prefWidthProperty().bind(widthProperty);
cell.minWidthProperty().bind(widthProperty);
}
public static void smoothScrolling(ScrollPane scrollPane) {
if (AnimationUtils.isAnimationEnabled())
ScrollUtils.addSmoothScrolling(scrollPane);

View File

@@ -189,6 +189,7 @@ public final class JavaManagementPage extends ListPageBase<JavaRuntime> {
JavaPageSkin(JavaManagementPage skinnable) {
super(skinnable);
this.listView.getStyleClass().add("no-horizontal-scrollbar");
}
@Override
@@ -210,7 +211,7 @@ public final class JavaManagementPage extends ListPageBase<JavaRuntime> {
@Override
protected ListCell<JavaRuntime> createListCell(JFXListView<JavaRuntime> listView) {
return new JavaItemCell();
return new JavaItemCell(listView);
}
}
@@ -222,7 +223,7 @@ public final class JavaManagementPage extends ListPageBase<JavaRuntime> {
private final StackPane removeIconPane;
private final Tooltip removeTooltip = new Tooltip();
JavaItemCell() {
JavaItemCell(JFXListView<JavaRuntime> listView) {
BorderPane root = new BorderPane();
HBox center = new HBox();
@@ -272,6 +273,8 @@ public final class JavaManagementPage extends ListPageBase<JavaRuntime> {
root.setPadding(new Insets(8));
this.graphic = new RipplerContainer(root);
FXUtils.limitCellWidth(listView, this);
}
@Override

View File

@@ -558,11 +558,8 @@ public class DownloadListPage extends Control implements DecoratorPage, VersionP
setPrefWidth(0);
if (listView.lookup(".clipped-container") instanceof Region clippedContainer) {
maxWidthProperty().bind(clippedContainer.widthProperty());
prefWidthProperty().bind(clippedContainer.widthProperty());
minWidthProperty().bind(clippedContainer.widthProperty());
}
FXUtils.limitCellWidth(listView, this);
}
@Override

View File

@@ -955,6 +955,13 @@
-fx-background-color: transparent;
}
.no-horizontal-scrollbar .scroll-bar:horizontal {
-fx-opacity: 0;
-fx-max-height: 0;
-fx-min-height: 0;
-fx-pref-height: 0;
}
.options-list {
-fx-background-color: transparent;
-fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.26), 5, 0.06, -0.5, 1);