Home Answers Viewqa Java-Beginners Open InternetExplorer Webpage with Java

 
 


shweta
Open InternetExplorer Webpage with Java
1 Answer(s)      3 years and 2 months ago
Posted in : Java Beginners

Hello Sir I want to Open my webpage from swing application when I Click On
"VISIT US" Boutton then website will be display
How I can Create it on Button Click.
View Answers

March 20, 2010 at 4:23 PM


Hi Friend,

Try the following code:

1)OpenBrowser.java

import javax.swing.*;
import java.lang.reflect.Method;

public class OpenBrowser {
public static void openURL(String url) {
String osName = System.getProperty("os.name");
try {
if (osName.startsWith("Windows"))
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url);
else {
String[] browsers = {"firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape" };
String browser = null;
for (int count = 0; count < browsers.length && browser == null; count++)
if (Runtime.getRuntime().exec(new String[] {"which", browsers[count]}).waitFor() == 0)
browser = browsers[count];
Runtime.getRuntime().exec(new String[] {browser, url});
}
}
catch (Exception e) {
JOptionPane.showMessageDialog(null, "Error in opening browser" + ":\n" + e.getLocalizedMessage());
}
}
}

2)Browser.java

import javax.swing.*;
import java.awt.event.*;

public class Browser {
public static void main(String[] args) {
JFrame frame = new JFrame();
JPanel panel = new JPanel();
final JTextField url =new JTextField(20);
JButton button = new JButton("Open Browser");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
OpenBrowser.openURL(url.getText().trim()); }
} );
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
panel.add(new JLabel("URL:"));
panel.add(url);
panel.add(button);
frame.getContentPane().add(panel);
frame.pack();
frame.setVisible(true);
}
}

Hope that it will be helpful for you.
Thanks









Related Pages:
Open InternetExplorer Webpage with Java - Java Beginners
Open InternetExplorer Webpage with Java  Hello Sir I want to Open my webpage from swing application when I Click On "VISIT US" Boutton then website...(); final JTextField url =new JTextField(20); JButton button = new JButton("Open
webpage
webpage  java, servlet and JSPs to create a web page with a text box and a button named submit. after submitting i shpuld get a msg successfully added
Last modified time of a webpage
Last modified time of a webpage  how can we get the last modified time of a webpage using java
webpage
webpage  design a webpage student database using forms and frameset
How to export the table content from an webpage to excel using java?
How to export the table content from an webpage to excel using java?  How to export the table content from an webpage to excel using java? The table contents are generated dynamically in that java page
How to export the table content from an webpage to excel using java?
How to export the table content from an webpage to excel using java?  How to export the table content from an webpage to excel using java? The table contents are generated dynamically in that java page
how to send the content of jtextarea from netbeans IDE to webpage's textarea in java
how to send the content of jtextarea from netbeans IDE to webpage's textarea in java   Hi, i m interested to send the content of my jtextarea which i have developed in netbeans IDE to the webpage's textarea. how can i do
Parent child windows relationships when webpage is accesssed through a hyperlink.
Parent child windows relationships when webpage is accesssed through a hyperlink.  A particular session timeout functionality works when a webpage is loaded. The webpage has parent/child windows. This timeout functionality works
webpage capture
webpage capture   webpage capture source code using jsps and servlets
How to find the size of a dynamic webpage using java... eg : Youtube........
How to find the size of a dynamic webpage using java... eg : Youtube........  package newpack; import java.io.BufferedInputStream; import...... Please help... Thanks, Ramit   the above code is running on JAVA
open document
open document  open a word document using jsp   Please go through the following link: Java Read word document file The above link will provide an example that will read the document file using POI library in java
how to open java
how to open Java  how to open java file simple Java Example
How to add google page in my webpage using jquery ajax.
How to add google page in my webpage using jquery ajax.  Hi, I created a page index.html on desktop . this page content following code. <html>... not open on my browser. how google page will load using ajax. thanks
open source - Java Beginners
open source  hi! what is open source? i heard that SUN has released open source .what is re requisite to understand that open source. i know core concepts only  Hi friend, Open source is an approach to design
copy something from a webpage to my webpage
copy something from a webpage to my webpage  How can I copy something from a webpage to my webpage
Open Source Testing Tools in Java
Open Source Testing Tools in Java
Java open source software
Open source software for Java In this page we will tell list down the most used Open source in Java. Java is one of the programming language used... is the list of java open source software used for the development and deployment
open source project
open source project  i am a b.tec 3rd year ,i want to work in some open source java project, please suggest me
Showing div at the center of the webpage
Showing div at the center of the webpage  Showing div at the center of the webpage
open word document
open word document  how to open a word document ??   Please go through the following link: Java Read word document file The above link will provide an example that will read the document file using POI library in java
open word document
open word document  how to open a word document ??   Please go through the following link: Java Read word document file The above link will provide an example that will read the document file using POI library in java
open word document
open word document  how to open a word document ??   Please go through the following link: Java Read word document file The above link will provide an example that will read the document file using POI library in java
open taps CRM
open taps CRM  hi Plese guide to me how to forecase in Java Ofbiz Opentaps CRM Module Thanks hasim
How to open an Acroform in iText?
How to open an Acroform in iText?  I modified a client's Acroform in Acrobat Pro 9, and now the client says he can't open it in iText. I had never even heard of iText before this. It's been a while since I did any Java coding
Will i be able to get the content of a webpage in a word document (Note:i don t have access to the source code)through java code?
Will i be able to get the content of a webpage in a word document (Note:i don t have access to the source code)through java code?  public class... document to the webpage(for which i don t have access to source code
open source help desk
Open Source Help Desk Open Source Help Desk Software As my help desk... of the major open source help desk software offerings. I?m not doing... or two. What I?m really looking to do is build relationships with the best open
java code to open and display MS-word document
java code to open and display MS-word document  java code to open and display MS-word document
How to open a file in java using JFileChooser
How to open a file in java using JFileChooser  How to open a file in java using JFileChooser
Open Jgraph Problem - Java Beginners
Open Jgraph Problem  Hi, I have go through the example given in http://sourceforge.net/projects/openjgraph/ for Open Jgraph by Jesus M. Salvo Jr... on this. I am a newbie in Java language. Thank you. Ulamraja
Open Source software written in Java
Open Source software written in Java Open Source Software  or OSS... Code Coverage Open Source Java Collections API... Purpose ERP/CRM Written in Java Open Source
Open Source Software
; Open Source Aspect-Oriented Frameworks in Java AspectJ...Open Source Software Open Source Software Open source doesn't just mean access to the source code
Open Source DRM
Open Source DRM SideSpace releases open source DRM solution SideSpace Solutions released Media-S, an open-source DRM solution. Media-S is format-independent, though the first release only supports the Ogg Vorbis open-source audio
Open Source Jobs
transfers.     Open Source Job Schedulers in Java On some... developers and architects how to integrate Quartz with leading open source Java...Open Source Jobs Open Source Professionals Search firm
Open Source HTML
;   Open Source HTML Parsers in Java NekoHTML is a simple HTML...Open Source HTML HTML Tidy Library Project A quorum... element tags.       Open Source Search Engines
Open Source Directory
Open Source Directory Open Source Java Directory The Open Source Java... Java Open Application Server and Tomcat, part of the Apache Jakarta Project... - to many different platforms.    Open Source Java Directory
how to open a file with a jbutton? - Java Beginners
how to open a file with a jbutton?  Hello Is it possible that by clicking on a button it can open java html file or doc exists on the pc? I searched and I found that it is possible to open a web page so I tried to open
Open TextFile on JButton Click - Java Beginners
Open TextFile on JButton Click  Hello Sir I Want to open TextFile on JButton Click. plz Help Me  Hi Friend, Do you want to simply open the text file or you want to open the file using JFileChooser,read that file
Open Source Midi
Sound API package (javax.sound.midi). Plumstone is an open source Java project...Open Source Midi Open Source Midi Proprietary software Being the best... share. As proponents of open source software, it should not be beneath us
Open-jACOB
Open-jACOB       Open-jACOB is a Java rapid application development tool (RAD) based on Eclipse... on Ajax with Java backend. Read full Description
Open Source Software
Open Source Software In this section we are discussing Open source software... Open source software available on the internet that can be used in the company. Open source software is very useful because source code also distributed
Open Source JMS
Open Source JMS Open Source JMS OpenJMS is an open source implementation of Sun Microsystems's Java Message Service API 1.0.2 Specification. Features... detection .    Open Source JMS Implementations JMS4Spread
Open Source Business,What is OSS,Advantage of Open Source in Business
, the algorithm of open source software is far different and mostly OSS is java-based...Open Source for Business Earlier it was uncommon to use the open source... and it was awful to learn all the commands of different open source software
Open Source Project Management
Open Source Project Management Open Source Project Management... to access our support forums.      An Open-Source Based... of project-open and its developer community. This page is designed for software
Open Source Groupware
Open Source Groupware Open Groupware  Open Group 1.1.4 is the fourth official trunk snapshot (alpha) of the upcoming Open Group... to generate links to open files from the local filesystem as well as highly
open source web services tool java
Open Source web services tool in java        ...: The Web Services Invocation Framework (WSIF) is a simple Java API
Java Swing Open Browser
Java Swing Open Browser Java provides different methods to develop useful... that will open the specified url on the browser using java swing. This example will really...("Open Browser"); button.addActionListener(new ActionListener() { public
Open website on Button Click - Java Beginners
Open website on Button Click  Hello sir I want to open website on button click using java swing plz help me sir. in my swing application one "VISIT US BUTTON" i want to open my website on Button CLick  Hi Friend
Open Source Community
Open Source Community Open Source Research Community In the spirit of free and open source software (F/OSS), we are attempting to establish... further the understanding of open source and its implications outside the realm
How to print a webpage without url and date in jsp ?
How to print a webpage without url and date in jsp ?  How to print a webpage without url and date in jsp
How to Open Text or Word File on JButton Click in Java - Java Beginners
How to Open Text or Word File on JButton Click in Java  How to Open Text or Word File on JButton Click in Java

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.