-
Bug
-
Resolution: Not an Issue
-
P4
-
7u40
-
java version "1.7.0_12-ea"
Java(TM) SE Runtime Environment (build 1.7.0_12-ea-b07)
Java HotSpot(TM) 64-Bit Server VM (build 24.0-b28, mixed mode)Ubuntu / KDE
The JavaFX FileChooser doesn't work well when multiselecting many files (say, 100).
Sample code:
import java.io.File;
import java.util.List;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextAreaBuilder;
import javafx.scene.layout.VBox;
import javafx.scene.layout.VBoxBuilder;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
public class Bug extends Application
{
public static void main(String[] args)
{
launch(args);
}
@Override
public void start(final Stage primaryStage)
{
primaryStage.setTitle("bug");
Group root = new Group();
final TextArea textArea = TextAreaBuilder.create().prefWidth(400).wrapText(true).build();
Button buttonLoad = new Button("open files");
buttonLoad.setOnAction(new EventHandler<ActionEvent>()
{
@Override
public void handle(ActionEvent arg0)
{
FileChooser fileChooser = new FileChooser();
// Show save file dialog
List<File> files = fileChooser.showOpenMultipleDialog(primaryStage);
System.out.println(files.size());
textArea.setText("Ok, done - " + files.size());
System.out.println("setText call finished");
}
});
VBox vBox = VBoxBuilder.create().children(buttonLoad, textArea).build();
root.getChildren().add(vBox);
primaryStage.setScene(new Scene(root, 500, 400));
primaryStage.show();
}
}
So, if you click the button to display the file chooser, it comes up as expected. Multiselect many files (say, about 100).
You will the "System.out.println(files.size());" print to the console immediately after you click ok on the file chooser.
At this point, the file chooser should be hidden - it has already handed us the file list.
However, what I observe is the file chooser stays on the screen for about 10 seconds. CPU Usage goes to 100%, and the entire JavaFX app stops repainting.
About 10 seconds later, the file chooser finally goes away, and the FX app starts repainting per normal.
I have been unable to determine what on earth the FX thread is doing during these 10 seconds.
Sample code:
import java.io.File;
import java.util.List;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextAreaBuilder;
import javafx.scene.layout.VBox;
import javafx.scene.layout.VBoxBuilder;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
public class Bug extends Application
{
public static void main(String[] args)
{
launch(args);
}
@Override
public void start(final Stage primaryStage)
{
primaryStage.setTitle("bug");
Group root = new Group();
final TextArea textArea = TextAreaBuilder.create().prefWidth(400).wrapText(true).build();
Button buttonLoad = new Button("open files");
buttonLoad.setOnAction(new EventHandler<ActionEvent>()
{
@Override
public void handle(ActionEvent arg0)
{
FileChooser fileChooser = new FileChooser();
// Show save file dialog
List<File> files = fileChooser.showOpenMultipleDialog(primaryStage);
System.out.println(files.size());
textArea.setText("Ok, done - " + files.size());
System.out.println("setText call finished");
}
});
VBox vBox = VBoxBuilder.create().children(buttonLoad, textArea).build();
root.getChildren().add(vBox);
primaryStage.setScene(new Scene(root, 500, 400));
primaryStage.show();
}
}
So, if you click the button to display the file chooser, it comes up as expected. Multiselect many files (say, about 100).
You will the "System.out.println(files.size());" print to the console immediately after you click ok on the file chooser.
At this point, the file chooser should be hidden - it has already handed us the file list.
However, what I observe is the file chooser stays on the screen for about 10 seconds. CPU Usage goes to 100%, and the entire JavaFX app stops repainting.
About 10 seconds later, the file chooser finally goes away, and the FX app starts repainting per normal.
I have been unable to determine what on earth the FX thread is doing during these 10 seconds.