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

[Button] Default value of Button.alignment is not honoured

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • 9
    • 8u40
    • javafx

      If you run the code below, you get:
         1) a stage with an Hello button whose title is centred
         2) the "button.getAlignment()=CENTER_LEFT" on stdio
      => BUG: Hello title should be aligned on the left

      However if you uncomment the line
      // button.setAlignment(Pos.CENTER_LEFT);
      and run the code again, the label is now aligned on the left.

      So Button class does not honour the default value of Button.alignment property.
      But it honours any subsequent setting.



      package buttonalignmenttest;

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.stage.Stage;

      public class ButtonAlignmentTest extends Application {

          public static void main(String[] args) {
              Application.launch(args);
          }
          
          @Override
          public void start(Stage primaryStage) throws Exception {
              final Button button = new Button("Hello");
              System.out.println("button.getAlignment()=" + button.getAlignment());
      // button.setAlignment(Pos.CENTER_LEFT);
              final Scene scene = new Scene(button);
              primaryStage.setScene(scene);
              primaryStage.setWidth(300.0);
              primaryStage.show();
          }
          
          
      }

            jgiles Jonathan Giles
            eleponn Eric Le Ponner
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: