Jeetesh Nataraj
Jeetesh Nataraj

Reputation: 608

JFile Chooser Query

How to display JFile-Chooser at the Center of the screen. The conventional method of using ToolKit is not working.

Upvotes: 0

Views: 166

Answers (1)

Boris Pavlović
Boris Pavlović

Reputation: 64632

Check out Javadoc for the method JFileChooser#showDialog(Component parent, String approveButtonText) throws HeadlessException, it says:

The parent argument determines two things: the frame on which the open dialog depends and the component whose position the look and feel should consider when placing the dialog. If the parent is a Frame object (such as a JFrame) then the dialog depends on the frame and the look and feel positions the dialog relative to the frame (for example, centered over the frame). If the parent is a component, then the dialog depends on the frame containing the component, and is positioned relative to the component (for example, centered over the component). If the parent is null, then the dialog depends on no visible window, and it's placed in a look-and-feel-dependent position such as the center of the screen.

Upvotes: 3

Related Questions