ADDITIONAL SYSTEM INFORMATION :
x86 / Windows 11 / Java 23.0.1
A DESCRIPTION OF THE PROBLEM :
There's a bug whenever using a ToolBar on Windows if you set the resolution scale > 100%. E.g., 125%, where the ToolBar might create the overflow menu despite there being plenty of available space. This is down to a rounding error where two numbers should be regarded as equal but are not.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Very easy to reproduce the above, set your scale to 125% and run this:
public class ToolbarBugApp extends Application {
@Override
public void start(Stage primaryStage) {
BorderPane bp = new BorderPane();
// Wrapping in HBox and using button with 13+ chars causes bug
bp.setTop(new HBox(new ToolBar(new Button("Create Schema")))); // BUG
// bp.setTop(new ToolBar(new Button("Create Schema"))); // NO BUG (no HBox)
// bp.setTop(new HBox(new ToolBar(new Button("Create Schem")))); // NO BUG (12 chars)
primaryStage.setScene(new Scene(bp, 600, 400));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
That the ToolBar does not render the overflow menu.
ACTUAL -
The ToolBar does renders the overflow menu.
---------- BEGIN SOURCE ----------
As above. If it doesn't work for you, try different string lengths.
The bug can be found in ToolBarSkin's getOverflowNodeIndex(double length), where "x" and "length" are not equal when they should be (due to a very tiny rounding error). When x > length, it incorrectly assumes that overflow is required.
---------- END SOURCE ----------
x86 / Windows 11 / Java 23.0.1
A DESCRIPTION OF THE PROBLEM :
There's a bug whenever using a ToolBar on Windows if you set the resolution scale > 100%. E.g., 125%, where the ToolBar might create the overflow menu despite there being plenty of available space. This is down to a rounding error where two numbers should be regarded as equal but are not.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Very easy to reproduce the above, set your scale to 125% and run this:
public class ToolbarBugApp extends Application {
@Override
public void start(Stage primaryStage) {
BorderPane bp = new BorderPane();
// Wrapping in HBox and using button with 13+ chars causes bug
bp.setTop(new HBox(new ToolBar(new Button("Create Schema")))); // BUG
// bp.setTop(new ToolBar(new Button("Create Schema"))); // NO BUG (no HBox)
// bp.setTop(new HBox(new ToolBar(new Button("Create Schem")))); // NO BUG (12 chars)
primaryStage.setScene(new Scene(bp, 600, 400));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
That the ToolBar does not render the overflow menu.
ACTUAL -
The ToolBar does renders the overflow menu.
---------- BEGIN SOURCE ----------
As above. If it doesn't work for you, try different string lengths.
The bug can be found in ToolBarSkin's getOverflowNodeIndex(double length), where "x" and "length" are not equal when they should be (due to a very tiny rounding error). When x > length, it incorrectly assumes that overflow is required.
---------- END SOURCE ----------
- relates to
-
JDK-8364088 ToolBarSkin: NPE in select()
-
- Resolved
-
- links to
-
Review(master) openjdk/jfx/1856