Hi

Can someone help me, I have been trying to fix this for a while without any luck. I am new to JAVA programming though I have coded in many languages.

What I am trying to do is use the JFileChooser class in a Windows 2000 environment, the user can type the full path of a file into the File Name field and the directory is displayed. If I type a host name e.g. \\HOSTNAME returns HOSTNAME in the File Name field and the File view does not change (compare this to Explorer and you would see the sharenames). If I then type in a Host and share name (\\HOSTNAME\ShareName) I get a folder contents. This is just a little annoying but work aroundable by typing \\HOSTNAME\ShareName and navigating upwards.

The real problem occurs when the sharename is mis-spelt. I work in a large organisation and have access to many Hosts, typing a wrong file path can take several minutes for the application to timeout before I can change it. Explorer does not hang but allows you to correct the path and try again. Warning the user later that he had mis-typed.

Does anyone know how to thread the File Name text box to stop this??

Thanks in Advance

Craig

Recommended Answers

All 3 Replies

Well, the verification is occurring in BasicFileChooserUI.ApproveSelectionAction. If it's really worth it to you, you might be able to extend the necessary classes to provide an interruptible threaded implementation, but it might get stickier than you expect.

I don't know all of your requirements, but it might be more straightforward to just create your own file browser to provide the functionality you need.

I was hoping that I could just thread the File Name text box or really updating of the File Folder List. Pressing enter in the text box would set the update going, if a key is then pressed in the text box I want the update thread to be killed with only a new thread starting once the enter key is again pressed.

As my Java knowledge is limited made me think that by using the JFileChooser class would be a quick way to get my application moving, it seems as I have now spent many hours on this the way forward may be as you say to create my own class.

Thanks anyway

I was hoping that I could just thread the File Name text box or really updating of the File Folder List. Pressing enter in the text box would set the update going, if a key is then pressed in the text box I want the update thread to be killed with only a new thread starting once the enter key is again pressed.

Yes, that would probably be possible with the subclassing that I mentioned, but due to the layered and platform-independent UI delegation under the hood of the JFileChooser, changing that behavior requires a deeper understanding of the Swing component architecture and communication mechanisms to make sure all of the appropriate abstractions are satisfied and event notifications are handled appropriately.

It wouldn't hurt anything to give it a try if you really wanted to dig into it - you may get it just right! If you are fairly inexperienced with Swing and threading in Java though, it could be a pretty daunting jump into the deep end.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.