Re: [Swing] Is it possible to invoke a webpage using the default browser by pressing a JButton?



Pseudo Silk Kimono <Pseudo_Silk_Kimono@xxxxxxxxxxxxx> wrote in
news:fc700o$f71$1@xxxxxxxxxxxxxxxxxxxxxxxxx:

I am in the process of designing a very simple menu system which will
have a series of button, a sort of hierarchical system if you will.
What I would like to do is have each button open a webpage in the
user's default browser. Is this possible and if so, are there any
examples that someone would be willing to share? I have googled, but
either I am not searching for the right thing, or there are NO
websites which meet my criteria.


If using 1.6, java.awt.Desktop is the way to go.

try {
Desktop.browse(new URL("http://www.rgagnon.com";);
}
catch (MalformedURLException e1) {
e1.printStackTrace();
}
catch (DesktopException e2) {
e2.printStackTrace();
}

For pre 1.6, you need to use Runtime.exec() and the file association
mechanism of the OS.

Bye.
--
Real Gagnon from Quebec, Canada
* Java, Javascript, VBScript and PowerBuilder code snippets
* http://www.rgagnon.com/howto.html
* http://www.rgagnon.com/bigindex.html
.



Relevant Pages