Re: [Swing] Is it possible to invoke a webpage using the default browser by pressing a JButton?
- From: Real Gagnon <realgag+usenet@xxxxxxxxxxxxx>
- Date: Tue, 11 Sep 2007 21:51:18 GMT
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
.
- Follow-Ups:
- Re: [Swing] Is it possible to invoke a webpage using the default browser by pressing a JButton?
- From: Pseudo Silk Kimono
- Re: [Swing] Is it possible to invoke a webpage using the default browser by pressing a JButton?
- References:
- [Swing] Is it possible to invoke a webpage using the default browser by pressing a JButton?
- From: Pseudo Silk Kimono
- [Swing] Is it possible to invoke a webpage using the default browser by pressing a JButton?
- Prev by Date: [Swing] Is it possible to invoke a webpage using the default browser by pressing a JButton?
- Next by Date: Re: [Swing] Is it possible to invoke a webpage using the default browser by pressing a JButton?
- Previous by thread: [Swing] Is it possible to invoke a webpage using the default browser by pressing a JButton?
- Next by thread: Re: [Swing] Is it possible to invoke a webpage using the default browser by pressing a JButton?
- Index(es):
Relevant Pages
|