Hi All,

How can i get the swing/awt open and save dialog boxes while accessing from the client side ???

Recommended Answers

All 22 Replies

What code is controlling the dialog boxes?
Where is that code executing?

Is there a server involved? How does the server communicate with the client?

Below is some code I took from a recent project with a JFileChooser. I hope this is what you mean. The class this was in extended JFrame.

private JFileChooser chooser = new JFileChooser ();
//....//
chooser.setDialogTitle ("myTitle");
			chooser.setFileSelectionMode (JFileChooser.FILES_ONLY);
			chooser.setAcceptAllFileFilterUsed (true);
			chooser.setFileFilter (new ExtensionFileFilter (".txt", new String[] {"text" }));

			if (chooser.showSaveDialog (this) == JFileChooser.APPROVE_OPTION) {
				String selectedPath = chooser.getSelectedFile ().getPath ();
				// do something fun with the path/file 
			}

The dialog box opened but when i access this from a remote machine, it is still opening in the host where i hosted the tomcat server. Is there any way to bring the open/save dialog box in the remote machine when i access from remotely? pls help

Oh that's new for me.

You would have to run the progrm on te client computer, and let the two programs interact. I've never done that myself.

i too have stucked in the same problem.
MAX, which editor you are using, Netbeans or Eclipse?

The dialog box opened but when i access this from a remote machine,

On which machine is the dialog box open? On the server or on the remote machine?

What code are you executing on the server and what code on the remote machine?


Are you saying that when you execute code on the remote machine that a dialog box opens on the server? Why would the code do that? The human is at the remote machine so that is where the dialog should open.

I am using Eclipse IDE...

On which machine is the dialog box open? On the server or on the remote machine?

What code are you executing on the server and what code on the remote machine?

Are you saying that when you execute code on the remote machine that a dialog box opens on the server? Why would the code do that? The human is at the remote machine so that is where the dialog should open.

Here is my code,

ImportServer.java

package importServer;

import java.awt.FileDialog;
import java.awt.Frame;


public class ImportServer extends Frame {

    public static void action(){

        FileDialog fc; 
        fc = new FileDialog(new Frame(),"Open file", FileDialog.LOAD);
        fc.setDirectory(".");
        fc.setVisible(true);
        String path=fc.getDirectory (  )  + fc.getFile (  ) ; 
        System.out.println(path);

    }

      public static void main(String[] a) {
        action();
      }

}

When i execute this code from remote machine, the dialog box gets opened in the machine where i hosted the code and not in the remote machine. I have tried with JNLP, since JNLP requires the jar file of ImportServer.java, i have created the jar file.I dont know how to get the value of String variable path through JNLP. Need clarity on this.

Here is my JNLP code,

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="http://127.0.0.1:8080/" href="importServer.jnlp">
  <information>
    <title>Import Server</title>
    <vendor>XYZ</vendor>
  </information>
  <resources>
    <!-- Application Resources -->
    <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
    <jar href="importServer.jar" main="true" />
  </resources>
  <application-desc
    name="Import Server"
    main-class="importServer.ImportServer"
    width="300"
    height="300">
  </application-desc>
  <update check="background"/>
</jnlp>

Even i have the same problem....Can you please help us out in this.....

When i execute this code from remote machine

How do you execute this code from the remote machine? What program do you execute?
Java, a browser, the IDE???

Its used in a web application and hosted in Apache tomcat...From remote machine i try to access in the browser....

What URL do you use in the browser?
What page is on the server that the browser is trying to read?

What does ApplicationName connect to? A page or a some code?

Since its a web application with Struts framework,it holds a context root with which the entire code can be accessed (For Eg:starting from login page).This web/dynamic application i have done using Eclipse IDE...

What I don't understand is: If the browser asks the server for a page, why does the server "execute" some java code on the sever? Why doesn't it read the requested page and return it to the browser?

It sounds like you have configured the server to "execute the requested page" instead of reading and returning it.

Actually, the welcome page will be shown when i hit the URL, the welcome page may be index.jsp or login.jsp. But the above java code will be executed when i click the submit button in the page and the page will be returnd to the browser.

Why does the server execute the code that opens a dialog window?

I want the program to open the open file dialog box to choose the file and the file path should be returned to the jnlp.

the program to open the open file dialog box to choose the file

Where is the program executing?

is a solution identified for this problem?

Because it was 4 years ago, and the people involved are no longer here, all the info we have is in this thread.

If you now have the same problem, or a similar one, please start your own new thread and someone will help.

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.