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

ComboBox popup list is wrong height the first time it is shown if setPrefWidth() is used

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8u5
    • Fix Version/s: 8u20
    • Component/s: javafx
    • Labels:
    • Environment:

      Behavior seen under Windows 7 64-bit Java8, Java8u5

      Behavior NOT seen under Windows 7 64-bit Java7u51, Java7u55

      Description

      The height of a ComboBox's popup is wrong the first time if its preferred width is set. This results in a scrollbar being displayed the first time. This even happens when setViewableRowCount() is called. Subsequent displays of the popup are the correct height. It appears if setWidth() is used instead the desired behavior is seen, but only under Java8.

      {code}
      package mirror;

      import javafx.application.*;
      import javafx.collections.*;
      import javafx.scene.*;
      import javafx.scene.control.*;
      import javafx.stage.*;

      public class MirrorCombo extends Application
      {
          @Override
          public void start( Stage stage )
          {
              stage.setScene( createScene( false ) );
              stage.show();
              Stage stage2 = new Stage();
              stage2.setScene( createScene( true ) );
              stage2.setX( stage.getX() + stage.getWidth() );
              stage2.setY( stage.getY() );
              stage2.show();
          }

          private Scene createScene( boolean setPrefWidth )
          {
              final Group group = new Group();
              Label c1 = new Label( "NO setPrefWidth" );
              c1.setLayoutX( 20 );
              ComboBox c2 = new ComboBox();
              c2.setVisibleRowCount( 3 );
              if ( setPrefWidth )
              {
                  c2.setPrefWidth( 110.0 );
                  c1.setText( "setPrefWidth" );
              }
              c2.setItems( FXCollections.observableArrayList( "Fred", "Marry", "Todd" ) );
              c2.setLayoutX( 100 );
              c2.setLayoutY( 50 );
              group.getChildren().addAll( c1, c2 );
              Scene scene = new Scene( group, 200, 200 );
              return scene;
          }

          public static void main( String[] args )
          {
              launch( args );
          }
      }
      {code}

        Attachments

          Activity

            People

            Assignee:
            jgiles Jonathan Giles
            Reporter:
            zheismannjfx Zac Heismann (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported: