Image

Imagetidalwav1 wrote in Imagejava_dev 😊hopeful

Listens: Tipper-Breaks Mix 2004

Why doesn't this work?

I wasn't sure whether to first ask this here or in Sun's Java Forums. I chose you guys. ;)

I've been working on a java clone of the media library component of Winamp, which searches for and lets you sort through music files on your computer. My program is called jMediaCat, and it is available from http://jmediacat.sf.net.

The actual search functionality of my program works fine. It's what happens literally in the code right before that that doesn't work fine (here's a snippet from the guiSearch() method; the full, slightly less commented/condensed source code is available from my site at http://test.joshdick.net/jmc17.java):

clearResultsList(); //Clears the text output area. This is not the problem.
appendToResultsList("Searching for media..."); //Adds text to the text output area.
try {
    songs = fillLibrary(userField.getText()); //fillLibrary fills a string array with a list of files it will find in a given pathname (userField's text.)
    //(Other code not shown)
    } catch (Exception FileNotFoundException) {
    clearResultsList();
    appendToResultsList("Directory is not accessible!");
}


The problem is that the program mysteriously never displays the "Searching for Media" message and goes right to actually searching for the media. I've tried putting the top two lines (the ResultsList stuff meant to display the message) inside and outside the try brackets, as well as in the method fillLibrary, and the message is never displayed. I know for a fact that the clearResultsList and appendToResultsList methods work fine because they're used elsewhere in the program. I was thinking the only thing that could be causing this problem is that the instructions to draw the "Searching" message on screen are sent, but all of the hard drive activity from fillLibary() starts right after that and the computer doesn't concentrate on actually drawing the message until *after* all of the hard drive activity (when the message changes, anyway.) I tried putting a delay (simple for-loop accumulator) in between the resultsList and fillLibrary lines to try to offset this, and it didn't make any difference. I have no idea why this message is never displayed...do I have to use multithreading or something (which I have no clue how to do?) I'm at my wit's end...any help would be appreciated!

Thanks in advance!