FULL PRODUCT VERSION :
java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
macOS High Sierra 10.13.2
Windows 10
A DESCRIPTION OF THE PROBLEM :
The pop-up menu of ChoiceBox becomes scroll display when there are many selection items, but does not automatically scroll display the selection item.
When the number of items in the pop-up menu changes from scrolling required amount to unnecessary amount, display of pop-up menu is distorted.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Start the sample application
2) Scroll the pop-up menu and select the last item
3) Click the Change items button
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The first menu item is selected and scrolled and displayed.
ACTUAL -
The scroll position of the popup menu is incorrect and the display menu item appears to be empty.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.application.Platform;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class ChoiceBoxChangeTest extends Application {
@Override
public void start(Stage stage) throws Exception {
ObservableList<String> items = FXCollections.observableArrayList();
ChoiceBox<String> choiceBox = new ChoiceBox<>(items);
for (int i = 0; i < 100; i++) {
items.add("Before: " + (i + 1));
}
choiceBox.getSelectionModel().selectLast();
Button changeButton = new Button("Change items and Show popup");
changeButton.setOnAction(event -> {
items.clear();
for (int i = 0; i < 10; i++) {
items.add("After: " + (i + 1));
}
choiceBox.getSelectionModel().selectFirst();
choiceBox.show();
});
Scene scene = new Scene(new VBox(choiceBox, changeButton), 400, 400);
stage.setScene(scene);
stage.show();
Platform.runLater(()->{
choiceBox.show();
});
}
public static void main(String[] args) {
launch(args);
}
}
---------- END SOURCE ----------
java version "9.0.4"
Java(TM) SE Runtime Environment (build 9.0.4+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.4+11, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
macOS High Sierra 10.13.2
Windows 10
A DESCRIPTION OF THE PROBLEM :
The pop-up menu of ChoiceBox becomes scroll display when there are many selection items, but does not automatically scroll display the selection item.
When the number of items in the pop-up menu changes from scrolling required amount to unnecessary amount, display of pop-up menu is distorted.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Start the sample application
2) Scroll the pop-up menu and select the last item
3) Click the Change items button
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The first menu item is selected and scrolled and displayed.
ACTUAL -
The scroll position of the popup menu is incorrect and the display menu item appears to be empty.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.application.Platform;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class ChoiceBoxChangeTest extends Application {
@Override
public void start(Stage stage) throws Exception {
ObservableList<String> items = FXCollections.observableArrayList();
ChoiceBox<String> choiceBox = new ChoiceBox<>(items);
for (int i = 0; i < 100; i++) {
items.add("Before: " + (i + 1));
}
choiceBox.getSelectionModel().selectLast();
Button changeButton = new Button("Change items and Show popup");
changeButton.setOnAction(event -> {
items.clear();
for (int i = 0; i < 10; i++) {
items.add("After: " + (i + 1));
}
choiceBox.getSelectionModel().selectFirst();
choiceBox.show();
});
Scene scene = new Scene(new VBox(choiceBox, changeButton), 400, 400);
stage.setScene(scene);
stage.show();
Platform.runLater(()->{
choiceBox.show();
});
}
public static void main(String[] args) {
launch(args);
}
}
---------- END SOURCE ----------
- relates to
-
JDK-8196037 ComboBox does not scroll to the selected item
-
- Open
-