Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8090721

[TableView] : Need a way to hide scrollbars

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • fx2.0.2
    • javafx

      We are building an app (trading) that needs to maximize the screen real estate. It displays lots of TableView's and having scrollbars really wastes a lot of space. There is no API to manipulate the visibility of the scroll bars. The following code "kind of" works, but changes I make directly to the skins often get trashed when the underlying data changes or layout occurs. I have to resort to re-hiding in listeners when data and/or layout changes.

      Note that the scrolling (via mouse wheel) still works, the scrollbars just aren't visible and dont take up any space.

      The attached image is an example of the kind of thing we need to do (more easily). It's an example of 3 independently scrollable tables butted up against each other. Visible scrollbars would ruin the experience (especially for the related buy/sell data in the first 2 tables).

          public static <S> void hideHScrollbar(final TableView<S> tableView) {
              for (Node n: tableView.lookupAll(".scroll-bar:horizontal")) {
                  if (n instanceof ScrollBarSkin) {
                      ScrollBarSkin scrollBarSkin = (ScrollBarSkin) n;
                      scrollBarSkin.setPrefHeight(0);
                      scrollBarSkin.setMaxHeight(0);
                      scrollBarSkin.setVisible(false);
                      break;
                  }
              }
          }

          public static <S> void hideVScrollbar(final TableView<S> tableView) {
              for (Node n: tableView.lookupAll(".scroll-bar:vertical")) {
                  if (n instanceof ScrollBarSkin) {
                      ScrollBarSkin scrollBarSkin = (ScrollBarSkin) n;
                      scrollBarSkin.setPrefWidth(0);
                      scrollBarSkin.setMaxWidth(0);
                      scrollBarSkin.setVisible(false);
                      break;
                  }
              }
          }

            Unassigned Unassigned
            cdayjfx Craig Day (Inactive)
            Votes:
            3 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Imported: