ADDITIONAL SYSTEM INFORMATION :
Microsoft Windows [Version 10.0.17134.765]
openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.3+7)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.3+7, mixed mode)
A DESCRIPTION OF THE PROBLEM :
LabeledSkinBase ignores result of isIgnoreText when computing min height. It leads to case when any Labeled component with graphic and with empty text has its height computed base on text height (when its bigger then graphics height.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Start application from given code, inspect two created buttons.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Both buttons has same height base on graphics height, because text is empty.
ACTUAL -
Buttons has different height because LabeledSkinBase#computeMinHeight ignores isIgnoreText method result.
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TitledPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.stage.Stage;
public class HeightIssue
{
public static void main( String[] args )
{
System.err.println( Runtime.version().toString() );
Application.launch( HeightIssue.MainFx.class, args );
}
public static class MainFx extends Application
{
@Override
public void start( final Stage primaryStage ) throws Exception
{
final var left = new TitledPane( "Small font", createButton( 10) );
final var right =
new TitledPane( "Big font", createButton( 20) );
final var hBox = new HBox( 5, left, right );
final BorderPane borderPane = new BorderPane( hBox );
borderPane.setPadding( new Insets( 5 ) );
Scene scene = new Scene( borderPane, 800, 600 );
primaryStage.setScene( scene );
primaryStage.show();
}
private static Button createButton( double aFontSize )
{
final Button button = new Button( );
button.setGraphic( new Rectangle( 5,5, Color.RED) );
button.setFont( Font.font( aFontSize ) );
return button;
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Parching LabeledSkinBase with solution proposed in https://bugs.openjdk.org/browse/JDK-8230833 solves this problem but is causing some tests to break, i patched only ButtonSkinBase and ToggleSkinBase with simmilar height computing as proposed there to have it working in my project.
FREQUENCY : always
Microsoft Windows [Version 10.0.17134.765]
openjdk version "11.0.3" 2019-04-16
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.3+7)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.3+7, mixed mode)
A DESCRIPTION OF THE PROBLEM :
LabeledSkinBase ignores result of isIgnoreText when computing min height. It leads to case when any Labeled component with graphic and with empty text has its height computed base on text height (when its bigger then graphics height.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Start application from given code, inspect two created buttons.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Both buttons has same height base on graphics height, because text is empty.
ACTUAL -
Buttons has different height because LabeledSkinBase#computeMinHeight ignores isIgnoreText method result.
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TitledPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.stage.Stage;
public class HeightIssue
{
public static void main( String[] args )
{
System.err.println( Runtime.version().toString() );
Application.launch( HeightIssue.MainFx.class, args );
}
public static class MainFx extends Application
{
@Override
public void start( final Stage primaryStage ) throws Exception
{
final var left = new TitledPane( "Small font", createButton( 10) );
final var right =
new TitledPane( "Big font", createButton( 20) );
final var hBox = new HBox( 5, left, right );
final BorderPane borderPane = new BorderPane( hBox );
borderPane.setPadding( new Insets( 5 ) );
Scene scene = new Scene( borderPane, 800, 600 );
primaryStage.setScene( scene );
primaryStage.show();
}
private static Button createButton( double aFontSize )
{
final Button button = new Button( );
button.setGraphic( new Rectangle( 5,5, Color.RED) );
button.setFont( Font.font( aFontSize ) );
return button;
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Parching LabeledSkinBase with solution proposed in https://bugs.openjdk.org/browse/JDK-8230833 solves this problem but is causing some tests to break, i patched only ButtonSkinBase and ToggleSkinBase with simmilar height computing as proposed there to have it working in my project.
FREQUENCY : always
- relates to
-
JDK-8230833 LabeledSkinBase computes wrong height with ContentDisplay.GRAPHIC_ONLY
-
- Resolved
-