Results 1 to 7 of 7
Thread: open a web page from JButton?
- 03-23-2012, 01:31 PM #1
Member
- Join Date
- Feb 2012
- Posts
- 43
- Rep Power
- 0
- 03-23-2012, 03:19 PM #2
Re: open a web page from JButton?
Create your button listener and give this a try.
I believe that the browser you have designated as your default browser will be used to render the webpage:
Java applications have an instance of the Runtime class that lets you connect to the environment that your application is running inside of (which can obviously vary). So to get this runtime, you call .getRuntime() on the Runtime class.Java Code:try { Runtime.getRuntime().exec("cmd /c start http://www.gmail.com"); } catch (IOException e) { System.out.println(e); }
Then, the exec method allows you to execute the string command that you pass to it. It would be the equivalent of running the command inside of a command promptLast edited by sehudson; 03-23-2012 at 03:36 PM.
- 03-24-2012, 06:58 AM #3
Member
- Join Date
- Feb 2012
- Posts
- 43
- Rep Power
- 0
Re: open a web page from JButton?
Awesome sir, you did it in such a simplified way...thank you sir
-
Re: open a web page from JButton?
But be sure to do this in a background thread so as not to freeze your Swing program.
- 03-26-2012, 05:56 PM #5
Member
- Join Date
- Feb 2012
- Posts
- 43
- Rep Power
- 0
Re: open a web page from JButton?
thanks for the advice
- 03-26-2012, 06:27 PM #6
- 03-27-2012, 02:37 AM #7
Similar Threads
-
JButton to open new Page
By knightwriter in forum AWT / SwingReplies: 6Last Post: 02-27-2012, 07:03 PM -
Open JPanel with JButton
By web_dev in forum New To JavaReplies: 7Last Post: 06-13-2011, 10:25 PM -
open text document using JButton
By coopc in forum New To JavaReplies: 3Last Post: 05-04-2011, 12:02 AM -
How To Open a JFrame Form from a jButton
By Lyricid in forum AWT / SwingReplies: 12Last Post: 03-28-2010, 06:53 AM -
how to click a jbutton and open an url
By katie in forum AWT / SwingReplies: 1Last Post: 08-06-2007, 10:44 PM


2Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks