Note that there are some explanatory texts on larger screens.

plurals
  1. POJFileChooser embedded in a JPanel
    text
    copied!<p>I am writing a java program that needs a file open dialog. The file open dialog isn't difficult, I'm hoping to use a <code>JFileChooser</code>. My problem is that I would like to have a dual pane <code>JFrame</code> (consisting of 2 <code>JPanels</code>). The left panel would have a <code>JList</code>, and the right panel would have a file open dialog. </p> <p>When I use <code>JFileChooser.showOpenDialog()</code> this opens the dialog box above all other windows, which isn't what I want. Is there any way to have the <code>JFileChooser</code> (or maybe another file selection dialog) display inside a <code>JPanel</code> and not pop-up above it?</p> <p>Here is the code that I've tried, at this point it's very simplified. I'm only trying to get the <code>JFileChooser</code> to be embedded in the <code>JPanel</code> at this point.</p> <pre><code>public class JFC extends JFrame{ public JFC() { setSize(800,600); JPanel panel= new JPanel(); JFileChooser chooser = new JFileChooser(); panel.add(chooser); setVisible(true); chooser.showOpenDialog(null); } public static void main(String[] args) { JFC blah = new JFC(); } } </code></pre> <p>I have also tried calling <code>chooser.showOpenDialog</code> with <code>this</code> and <code>panel</code>, but to no avail. Also, I have tried adding the <code>JFileChooser</code> directly to the frame. Both of the attempts listed above still have the <code>JFileChooser</code> pop up in front of the frame or panel (depending on which I add the <code>JFileChooser</code> to).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload