[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 160
  • Last Modified:

Open browser frame on double click

Hi,

I'm displaying images loaded from  a local folder in an applet. Is there any way in java to open a new broswer window to display the image using html? I guess the steps would look something like:

1) Handle double clikc in applet (no problem)
2) Create a new browser frame (don't know how to do this)
3) Give the browser a string of source html to render, something like:

     String str = "<html><img src = test.jpb></html>
     BrowserWindow win = new BrowserWindow;
     win.SetHtml(str);
     win.Show();

Yeah hopefully there is something like that!

Thanks
0
DJ_AM_Juicebox
Asked:
DJ_AM_Juicebox
  • 5
  • 4
1 Solution
 
CEHJCommented:
You could try

Runtime.exec("cmd.exe start /c " + absolutePathToImage);

for a Windows-only solution
0
 
DJ_AM_JuiceboxAuthor Commented:
Ah I don't think that will work for me - the applet is being run on a webpage on a server dislaying images local on the server.
0
 
DJ_AM_JuiceboxAuthor Commented:
This works:

try
            {
                java.applet.AppletContext a = getAppletContext();
                java.net.URL url = new java.net.URL("http://www.cnn.com");
                a.showDocument(url, "_blank");
            }
            catch (java.net.MalformedURLException ex)
            {
                System.out.println(ex.getMessage());
            }

but is there a way to instead of moving the user to a predefined URL, just created the html code yourself? I need to just display an image in a frame so the user can download it, like:

new URL_Code("<html><imgsrc = "hello.jpg"></html>

Thanks
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
objectsCommented:
You would achieve that using javascript to write the required html to the page.
0
 
DJ_AM_JuiceboxAuthor Commented:
But doesn't that require some java applet to javascript plugin? Where do I start?

Thanks
0
 
objectsCommented:
0
 
DJ_AM_JuiceboxAuthor Commented:
Arghh I guess I could do it but then I need an external dependency in the html page...
0
 
objectsCommented:
theres no other way really
0
 
objectsCommented:
perhaps you could have a html page that allowed you to pass the image path to display as a parameter (again using javascript) and load that.
or you'd need to dynamically generate the html on the server using jsp or similiar
0
 
DJ_AM_JuiceboxAuthor Commented:
blast, I was hoping java would be better suited for web development stuff.

I'm starting to think I should just do this in javascript!

Thanks
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now