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

Right hand slider label sometimes hidden

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Redhat Enterprise Linux 8.6, also repeated in Windows 10
      Java 11 and Java 21

      A DESCRIPTION OF THE PROBLEM :
      At certain font sizes and layout sizes the right hand slider label is hidden.

      I have isolated the bug to the private method javafx.scene.chart.Axis.updateTickMark(TickMark<T>, double, double, double, double, double). The issue appears to be a floating point rounding error.

      In the attached example using the debugger you can see that value of tick.getPosition() is 473.00000000000006, however the but parameter "length" is 473.

      This means that tick.getPosition() <= Math.ceil(length) is false which leads to tick.textNode.setVisible(false) being called.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the test example

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Label to be shown for 100
      ACTUAL -
      No label shown for 100

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Slider;
      import javafx.scene.layout.AnchorPane;
      import javafx.stage.Stage;

      public class MissingSliderLabel {

          public static void main(String[] args) {
              Application.launch(MissingSliderLabelApp.class, args);
          }

          public static class MissingSliderLabelApp extends Application {

              @Override
              public void start(Stage stage) {
                  AnchorPane pane = new AnchorPane();
                  Slider slider = new Slider(0, 100, 50);
                  slider.setMajorTickUnit(50);
                  slider.setShowTickLabels(true);
                  slider.setPrefWidth(492);
                  slider.setStyle("-fx-font-size: 16px");
                  pane.getChildren().add(slider);
                  stage.setScene(new Scene(pane));
                  stage.show();
              }
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Add manual padding to the RHS of the control. For example "-fx-padding:0 10 0 0"

      FREQUENCY : always


        1. Test.java
          0.9 kB
          Anupam Dev
        2. screenshot.png
          7 kB
          Anupam Dev

            adev Anupam Dev
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: