🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

More Info and bad Fix (was Re: JFileChooser and FileFilter)

#9163
From: Hogan Long
Date: Fri, 19 May 2000 00:00
70 lines
2713 bytes
I was having a similar problem with JFileChooser

My results (see example code below) where as
follows:
NOTES:
  All test were against a CD ROM with a sleep function
  The drive dir on the CD ROM are returned from the
  config.GetDir() call.

  1) when running in non-debug VM no problem.
  2) when running in debug VM crash
     (but not when I "steped" through the code.
  3) Code below tried to fix with a canRead() call...
     this seemed to make no difference - so it could 
     be removed in a test case
  4) the Thread.Sleep() function fixed the problem.
  5) SO... clearly this is a problem with the time it
     takes for messages in this component.
     BORLAND or SWING I don't know (or care really).

<PRE>
--->Start of example code

    JFileChooser chooser = null;

    File testDir = new File(config.GetDir());
    if (testDir.canRead())
      chooser = new JFileChooser(testDir);
    else
      chooser = new JFileChooser();

    chooser.setDialogTitle("Enter the directory to start the search
from");
    Thread.sleep(300);
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

    int returnVal = chooser.showOpenDialog(this);
----> End of example code
</PRE>

QUICK FIX SUGGESTIONS:
  - Add Thread.sleep(300) - or larger time around calls to
JFileChooser();
  - Comment them out till you find the min. needed to make it work.
  - Bitch about lame hacks and get on with your work.

Hogan

PS - If anyone knows more about this bug please email me at
hogan@akula.com
If I get a lot of replies I will post a summary.


Ilia Gilderman wrote:
> 
> Hi.
> 
> I'm trying to use setFileFilter or addChoosableFileFilter function of
> JFileChooser when I'm running not in the debug mode, everything is OK, and
> working fine, but when I'm trying to run it in the debug mode (JB3.5
> Shift+F9) I got the Runtime Error in the javaw.exe leading to "Abnormal
> Program Termination" More of this when I add breakpoint somewhere around
> chooser construction it stops there and when I continue it works fine.
> 
> Any ideas?
> 
> Thanks in advance
> 
> Ilia Gilderman
> ilia@iphighway.com
Technical Details
Message-ID: <3925EA90.44BCD338@akula.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <3902cd0a@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,fefb7295e563525e
X-Google-Attributes: gid111d45,public
From: Hogan Long <hogan@akula.com>
Subject: More Info and bad Fix (was Re: JFileChooser and FileFilter)
Date: 2000/05/19
Message-ID: <3925EA90.44BCD338@akula.com>
X-Deja-AN: 625597230
Content-Transfer-Encoding: 7bit
References: <3902cd0a@dnews>
Organization: Another Netscape Collabra Server User
Content-Type: text/plain; charset=us-ascii
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing