🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.swing
2 messages
2 total messages Started by Benji Shults Thu, 11 Nov 2004 20:03
JFileChooser doesn't pop up in console app
#896
Author: Benji Shults
Date: Thu, 11 Nov 2004 20:03
38 lines
1950 bytes
I am writing what is mainly a console application but
I would like a JFileChooser to pop up every once in
a while.  My code works when I run it using java on the
command line but no JFileChooser pops up when I run it
under JBuilder.

Here is a little code to illustrate.  If you comment out
the console IO, the JFileChooser pops up.  But if you
do some Console IO, the JFileChooser does not pop up
under JBuilder.  It works using the Sun command-line
tools.


import javax.swing.JFileChooser;
import javax.swing.JFrame;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;

public class Test {
  public static void main(String[] args) throws IOException {
    System.out.println("This is really a console app, OK?");
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    br.readLine();
    JFileChooser chooser = new JFileChooser();
//      JFrame dummy = new JFrame();
//      dummy.pack();
    int choice = chooser.showOpenDialog(null); // dummy);
    if (choice == JFileChooser.APPROVE_OPTION) {
      chooser.getSelectedFile();
    }
  }
}

Thanks,

Benji
Re: JFileChooser doesn't pop up in console app
#898
Author: John McGrath [TeamB]
Date: Sat, 13 Nov 2004 22:30
31 lines
2198 bytes
On 11/11/2004 at 3:03:35 PM, Benji Shults wrote:

> I am writing what is mainly a console application but
> I would like a JFileChooser to pop up every once in
> a while.  My code works when I run it using java on the
> command line but no JFileChooser pops up when I run it
> under JBuilder.
> 
> Here is a little code to illustrate.  If you comment out
> the console IO, the JFileChooser pops up.  But if you
> do some Console IO, the JFileChooser does not pop up
> under JBuilder.  It works using the Sun command-line
> tools.

You say that it the program works with "the Sun command-line tools", but
you did not say which version you used.  Did you use the same JDK that you
used within JBuilder?

Are you sure that you tested the *exact* same code using the command-line
tools that you used under JBuilder?  I tried the code you posted with JDK
1.5.0, JDK 1.4.2_05 and JDK 1.3.1_03, and it hangs up on the JFileChooser
with all of them.

-- 
Regards,

John McGrath [TeamB]

---------------------------------------------------
Before sending me e-mail, please read:
    http://www.JPMcGrath.net/newsgroups/e-mail.html
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads