The documented way to add controls to a JFileChooser
is via the setAccessory(JComponent) method.
JTextField field = new JTextField("Hello, World");
JPanel accessory = new JPanel();
accessory.setLayout(new FlowLayout());
accessory.add(field);
JFileChooser chooser = new JFileChooser();
chooser.setAccessory(accessory);
int ret = chooser.showOpenDialog(frame);
However, this will layout the new control on the right of the dialog (exact positioning is probably locale-dependent).
To locate the component to the position you want it, you'll probably have to walk the component graph and manipulate it. This would be a very fragile approach and you may be better off just building your own dialog.
This could incorporate a file chooser:
JFileChooser chooser = new JFileChooser();
chooser.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO - wire into something
System.out.println(e);
}
});
JTextField field = new JTextField("Hello, World");
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(chooser, BorderLayout.CENTER);
panel.add(field, BorderLayout.SOUTH);