I am new to applets and trying to solve this scenario. Any help is greatly appreciated.
I have a webpage where user needs to select a folder/directory instead of a file by browsing (same functionality when html browse button is clicked)
Get the folder path selected by the user and call a java program which would move it to a different location.
My implementation plan:
Create an applet with 'Browse' button and when clicked use JFileChooser() method to select only folder/directory.
Transfer selected folder path to java program.
How do I call JFileChooser functionality in my applet, what are the steps that need to be followed to achieve this functionality?
Once folder is selected, how to set it to a text field on the webpage so that user could see what was selected.
later when 'transfer' button is clicked, how to pass this selected folder path to my java code which does this move?
I went over FileChooser examples, it does exactly what I was looking for. Thanks.
Now When I select a folder/directory I want to show the selected path and provide 'OK' button instead of closing the applet. Is it adding another button and calling something like close() on clikc of it?
How do I show the selected path?
Joined: Mar 22, 2005
Where do you want to show it - in the applet or the web page?
Joined: Mar 29, 2005
First, I want to show it in the Applet, in a text field or to a label and when applet is closed want to show it on the webpage.
As I am thinking about it and implementing it, I got another question
Assume that I select a folder, how should I invoke my next code ie to move folder to another location.
Does all of this needs to be implemented in an applet? Select, display and then move.
As I am new to Applets, Swing, AWT, I would like your opinion about how much time would it need to implement this functionality and what are my options for implementation, if Applets is not the best option.
Joined: Mar 22, 2005
For showing it in the applet, add an empty JLabel when the GUI is created, and keep a reference to it around; then you can set the label's text later on.
when applet is closed want to show it on the webpage.
What does that mean? The applet won't be closed (or rather, stopped and discarded) until the page is closed, making a change of the page contents at that point a bit pointless.
how should I invoke my next code ie to move folder to another location.
Not sure what you mean by "invoke"; once you have the path of the directory, what stops you from doing all necessary file operations? In the easiest case, it would involve a single call to "new File(path).renameTo(...)".