🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #896

JFileChooser doesn't pop up in console app

#896
From: 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
Technical Details
Message-ID: <4193d3a7$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsread.com!newsprint.newsread.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 111d45,1f6004e8e376e531,start
X-Google-Attributes: gid111d45,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Benji Shults" <b-shults@bethel.edu>
Sender: "Benji Shults" <b-shults@bethel.edu>
Reply-To: "Benji Shults" <b-shults@bethel.edu>
Subject: JFileChooser doesn't pop up in console app
Newsgroups: borland.public.jbuilder.java.swing
X-User-Info: 140.88.25.240     
NNTP-Posting-Host: 207.105.83.66
Message-ID: <4193d3a7$1@newsgroups.borland.com>
Date: 11 Nov 2004 13:03:35 -0700
X-Trace: newsgroups.borland.com 1100207015 207.105.83.66 (11 Nov 2004 13:03:35 -0700)
Lines: 39
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsread.com!newsprint.newsread.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail