Upload file from desktop to Java applet application - java

How I can upload a file from desktop to Java applet application?
Create upload button.
Browse thought the desktop and choose the file.
Then create a link that enables the user to click on and open the chosen file.

use swing for example, just a button
use JFileChooser
It is not clear: do you want a link where ? (if it is on the web, you have to transmit it, or it can be on the applet: why not a button ?), and does it be called another time ?
General question: what is the purpose of this file ?

Related

How to handle FileUpload using selenium-Webdriver

//div[#id='upload_button']
driver.findElement(By.xpath("//div[#id='upload_button']")).click();
driver.findElement(By.xpath("//div[#id='upload_button']")).sendKeys("V://Images//CSV/text.csv");
I have a upload button in my browser
written a script that will click the button and send the mentioned file from given path
Here it is selecting the Upload button and file explorer opening
Not opening path, to send the csv file
If //input[#type='file'] is present at least one time in the HTML-DOM, the you can directly send the keys, you do not need to
Click on upload button
Select file using explorer
and upload the file.
This feature was introduced in one of the Selenium 3 versions.
Effective code:
driver.findElement(By.xpath("//input[#type='file']")).sendKeys("V://Images//CSV/text.csv");
I would recommend that use explicit wait for more stability.
driver.findElemnt(By.xpath("//input[#type='file'])).sendKeys(" give source file path");

How to drag and open file in editor?

I have a editor developed which opens the xml file and display it there (with the proper structure), for this I need to browse through all the times to select target file, in what way I can add dragging in file feature enable for this ?
The report editor is developed with Java SWT components.
I want to know the possible ways or API available for "dragging in" file ?
This link might help you.
DragSource class which provides the drag and drip API in SWT.
http://www.java2s.com/Tutorial/Java/0280__SWT/DraggingandDropping.htm

Download file, open it locally, edit and then upload

I have a web application that let users download files normally, and then later they can upload them using a simple upload mechanism (choose the files from directory and stuff).
Here's what I want to do: to have and "EDIT" button on my app, that download the file and open it automatically from the user's local drive. Then I want to check if there are changes, to upload it back to the server. Or, provide a way to the user upload it easily.
The options I've come so far, are:
Signed Applets
I find applets slow and "ugly". But it's the winning choice so far. It could download and open the file easily and then have an upload button, to put the file back on the server.
HTML 5 (File API)
I started looking into this and liked what I saw. But a lot of things that I saw are for local uploads, drag and drop and this kind of stuff. I'm very new to this technology and I simple don't know if it's doable.
A desktop application
I don't like this one but it's still on the table. It could one that monitors a directory created by an applet (here it's again), check if there are changes and then upload it back to the server.
Can someone provide me some help? If a can do something like that with HTML 5 or if there's a better solution.
You can't upload files without user interaction in HTML even if you try HTML5. That's against web fundemantals. The user has to trigger the file upload in a way, drag&drop, browse and select file, etc.
Signed applets might be a better solution than a desktop application because of the pain of the deployment.
If this file that you want your users to edit is just text based, I suggesst using an HTML based editor like Google does it for Google Docs.

Show HTML mark-up in JFrame or open Browser

I am writing a Java program that creates HTML code.
What's the best/easiest possibility to have a preview of the code?
Show the code in the JFrame: How can I do this?
Open the windows browser with the created File? Is this possible?
A totally different approach?
Both are quite easy to do. Here is a page from the Java tutorial that shows how to display HTML in Swing (you'd use a file: URL to display the contents of a file.) You can display a URL in an external browser using Java 6's Desktop class:
Desktop.getDesktop().browse(new URI("file://myfile.html"));
Alternately, save the data in a file with the *.html extension and use
Desktop.getDesktop().open(new File("myfile.html"));

Open an exe window

I want to customize the browser by adding a new button in the main menu the requirement is when i click on the button it should open an exe its working good by opening it in a new window i want the window to be displayed in the browser itself. eg. in mozilla firefox i give a button to open openoffice.exe. Its opening as a new window and i am able to close the browser by keeping the exe file opened. I want to open the exe file of open office in the browser so that when i click the link in the window it opens the new open office writer in the browser itself. Any idea how can i implement that
An exe file (Executable) file is an independent file. It will always run in its own window no matter from where it is called. If you want to open a document in your browser window, simple link the file created in that exe file. For example if you want to show a MS-Word document in the web browser, then instead of providing the link to MS-Word, provide a link to the Word documument (.doc or docx). Remember this behaviour requires that the linked files must have a registered application installed on the computer.

Categories