• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Open browser/web page from a swing app

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a Swing application, the application has a menu bar with a Help menu, the Help menu has an "Our Website" menu item.
I want to know what I need to do to make an event open a browser/web page. I know how to trap the action, I need to know what I need to do to open a browser.
Robert
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

where temp.html is a link to your web page ( or have it automatically redirect people to your site ).
p.s. for the redirect source code, just view the page source at javaranch after you submit a post ("Sit tight... We are taking you back to: ...")
Jamie
[ April 26, 2002: Message edited by: Jamie Robertson ]
 
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i once wanted to do the same thing. here is what i did although i am 100% sure there is a better way.

notice that the file://help.html can be replaced with any html documnet you got on your mcahine or input a URL using http:// instead.
also notice this will work ONLY in windows.
 
Robert Upshall
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, this worked.
I have another question now, are there any platform independant ways? ie. how might I do this in linux or Mac OS?
Robert
 
Roy Ben Ami
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i dont think there are any platform independant ways. cause the browser opens diffrently on every OS.
again i may be wrong
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And you also can't be sure of what browsers are installed or what directories they are installed in.... the only platform independent way to do this would be to have the user set up what browser they wanted to use with your program so you would know what command to run...

You could also use a JEditorPane... but since this just has basic HTML support, you'd end up coding your own browser if you wanted anything fancy like javascript...

-Nate
[ April 29, 2002: Message edited by: Nathan Pruett ]
 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wrote a class that will let you launch a url in a Browser on many platforms from your Java application:
http://ostermiller.org/utils/Browser.html
 
Roy Ben Ami
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
cool class.
well done!
reply
    Bookmark Topic Watch Topic
  • New Topic