Solved

Open file Browse

Posted on 1998-06-16
8
190 Views
Last Modified: 2010-04-16
How can make Open dialog brows to select a file or directory ?
0
Comment
Question by:a_sameer
  • 5
  • 3
8 Comments
 
LVL 5

Expert Comment

by:msmolyak
Comment Utility
What exactly you are trying to do? Is java.awt.FileDialog what you want?
0
 

Author Comment

by:a_sameer
Comment Utility
That's ok , But how can write this code in HTML
and where can found the class of this function .

Thanks ,,,
0
 
LVL 5

Accepted Solution

by:
msmolyak earned 150 total points
Comment Utility
The easiest thing to do is to use JavaScript. Alas, that would work only in Netscape Navigator 3.x and above.

<SCRIPT LANGUAGE="JavaScript">

var fileName;

/**
 * Display a file dialog and return a selected file.
 */
function getFile()
{
    var parentFrame = new java.awt.Frame();
    var fileDialog = new java.awt.FileDialog(parentFrame, "Select a file to print");
    fileDialog.setVisible(true);
    fileName = fileDialog.getDirectory() + fileDialog.getFile();
    alert("Selected file " + fileName);
}
</SCRIPT>

The necessary classes come with Netscape's Java support and you should not have to do anything to install these classes.
0
 

Author Comment

by:a_sameer
Comment Utility
ok , that's very good ... Thanks Msmolyak.

But I'm sorry ,, I want to select a Directory only (such as Empty Directory How can select it ?)



0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:a_sameer
Comment Utility
ok , that's very good ... Thanks Msmolyak.

But I'm sorry ,, I want to select a Directory only (such as Empty Directory How can select it ?)



0
 
LVL 5

Expert Comment

by:msmolyak
Comment Utility
I am afraid AWT does not posess this capability. It is possible, JavaScript has built-in functions to do that, I am not that familiar with JavaScript.  I will check what Swing has in that respect. I know Swing has a FileChooser but first of all it's in a preview stage, then I am not sure whether it can select directories and finally unlike AWT, Swing classes do not come with the browser so it will be harder to use them from JavaScript,
0
 
LVL 5

Expert Comment

by:msmolyak
Comment Utility
Swing;s FileChooset does not seem to support that either, which is only logical. It's hard to use the same interface for selecting both files and directories since double click ona file means "Select", whicl double click on a directory means "Expand". The oly place where I've seen directory selection dialogs is InstallShield when it asks you for the installation directory.
0
 
LVL 5

Expert Comment

by:msmolyak
Comment Utility
I'll take my last statement back. Swing's FileChooser does allow to choose directories only according to its description.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now