Results 1 to 3 of 3
- 09-10-2013, 02:34 AM #1
Senior Member
- Join Date
- Sep 2012
- Posts
- 108
- Rep Power
- 0
Desktop API - Opening system browser
What I am trying to accomplish is take a string given by a user in a JTextField, Pass that string to a JInternalFrame, and when I click on the JInternalFrame, have the systems default browser open using the supplied String passed into the JTextField. Code I have so far is below:
Java Code:@Override public void mouseClicked(MouseEvent arg0) { try { String x = billURL2.getText(); url = new URL("http://" + x); System.out.println(url); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { uri = new URI(url.toString()); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { desktop.browse(uri); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("MOUSE CLICKED"); } }); iFrame.show(); main.add(iFrame); } } }
- 09-10-2013, 03:15 AM #2
Senior Member
- Join Date
- Jan 2013
- Location
- Northern Virginia, United States
- Posts
- 6,226
- Rep Power
- 15
Re: Desktop API - Opening system browser
You need to show more of your code for me to help you. Did you assign an instance of Desktop to desktop? Are you checking that desktop is not null or that the URI is properly being obtained by the mouse? System.out.println() is your friend.
Regards,
JimThe JavaTM Tutorials | SSCCE | Java Naming Conventions
Poor planning on your part does not constitute an emergency on my part
- 09-10-2013, 03:31 AM #3
Senior Member
- Join Date
- Sep 2012
- Posts
- 108
- Rep Power
- 0
Similar Threads
-
opening an html file in default browser problems
By dhazwa in forum New To JavaReplies: 2Last Post: 08-22-2011, 06:42 AM -
opening default browser window in invisible mode
By robby14 in forum Advanced JavaReplies: 1Last Post: 02-20-2010, 02:50 AM -
[HELP]JButton opening a browser and opening a website[HELP]
By Learnin in forum AWT / SwingReplies: 4Last Post: 10-07-2009, 10:14 AM -
Opening Text Files with Default System Editor
By Pesch in forum Advanced JavaReplies: 5Last Post: 10-08-2008, 07:17 PM -
Q:App development that runs in a browser, also as a desktop on all platforms
By gsmurthy30 in forum New To JavaReplies: 2Last Post: 09-12-2008, 07:10 PM
Bookmarks