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

Menu slow to respond after resizing a window multiple times with animation running

XMLWordPrintable

        Run this sample program :

        "

        import javafx.animation.TranslateTransition;
        import javafx.application.Application;
        import static javafx.application.Application.launch;
        import javafx.scene.Scene;
        import javafx.scene.control.Label;
        import javafx.scene.control.Menu;
        import javafx.scene.control.MenuBar;
        import javafx.scene.control.MenuItem;
        import javafx.scene.layout.BorderPane;
        import javafx.stage.Stage;
        import javafx.util.Duration;

        public class testTranslate extends Application {

            @Override
            public void start(Stage primaryStage) {
                
                
                MenuBar bar =new MenuBar();

                for(int i =0;i<5; ++i){
                    Menu menu = new Menu("test");
                    for(int j =0;j<5; ++j){
                        MenuItem item = new MenuItem("test");
                        menu.getItems().add(item);
                    }
                    bar.getMenus().add(menu);
                }
                
                
                Label label = new Label("this is a test");
                TranslateTransition transition = new TranslateTransition(Duration.seconds(2), label);

                transition.setFromX(0);
                transition.setToX(1000);
                transition.setCycleCount(-1);
                transition.play();
                BorderPane pane = new BorderPane(label);
                pane.setTop(bar);
                pane.setMinWidth(1000);

                primaryStage.setTitle("Hello World!");
                primaryStage.setScene(new Scene(pane));
                primaryStage.show();
            }

            /**
             * @param args the command line arguments
             */
            public static void main(String[] args) {
                launch(args);
            }

        }
        "

        Click on one Menu, it appears immediately. Move your mouse on the other Menu, they all appear immediately.

        Now, resize the height of the window by grabbing the bottom. Resize the window by shrinking its height and enlarging it slowly like a user would. Repeat 5-6 times.

        Now try to open a Menu again, it is VERY slow to open. Why?
        What is the work-around for that?

              flar Jim Graham
              shadzic Samir Hadzic
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported: