?
Solved

Open file Browse

Posted on 1998-06-16
8
Medium Priority
?
228 Views
Last Modified: 2010-04-16
How can make Open dialog brows to select a file or directory ?
0
Comment
Question by:a_sameer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 5

Expert Comment

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

Author Comment

by:a_sameer
ID: 1223279
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 300 total points
ID: 1223280
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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 

Author Comment

by:a_sameer
ID: 1223281
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
 

Author Comment

by:a_sameer
ID: 1223282
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
ID: 1223283
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
ID: 1223284
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
ID: 1223285
I'll take my last statement back. Swing's FileChooser does allow to choose directories only according to its description.
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month12 days, 11 hours left to enroll

777 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