Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Open InternetExplorer Webpage with Java

Have Programming Question? Ask it here!
 
 
 


shweta
Open InternetExplorer Webpage with Java
1 Answer(s)      4 years and 5 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.

Advertisement
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 Tutorials/Questions & Answers:
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  design a webpage student database using forms and frameset
Advertisements
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
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
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
how to open java
how to open Java  how to open java file simple Java Example
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
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 - 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
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
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 Source Testing Tools in Java
Open Source Testing Tools in Java In this page we are discussing about the different Open Source Testing Tools available in Java. JUnit JUnit... by the developer who implements unit tests in Java. JUnit is Open Source Software
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
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
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
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
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
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 source web services tool java
Open Source web services tool in java        ...: The Web Services Invocation Framework (WSIF) is a simple Java API
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 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
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
open a bufferedwriter file in append mode - Java Beginners
open a bufferedwriter file in append mode  hi.. i jus want knw how to opena bufferedwriter file in append mode..  Hi friend, FileWriter...://www.roseindia.net/java/example/java/io/java-append-to-file.shtml Thanks
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
displaying a physical webpage with frames in iframe
displaying a physical webpage with frames in iframe  i have iframe in my webpage, i have done the coding part for browsing the folders and viewing... sources.i tried to display a sample webpage without frames and it was a success
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
Open Source Java Database
Open Source Java Database An Open Source Java Database One$DB is an Open Source version of Daffodil DB, our commercial Java Database. One$DB... Database One$DB is an Open Source version of Daffodil DB, our commercial Java
JSP - Problem of displaying result at webpage
JSP - Problem of displaying result at webpage  Can anyone please help to solve my problem below. My webpage has problem in displaying result position. The result should be display below my title. How do i solve it? Thank you so
Unable to open Java in full screen mode in Vista - Java Beginners
Unable to open Java in full screen mode in Vista  Hi iam facing a serious problem as my operating system is Windows-Vista.The editor always opens in minimized mode.If i try Alt+enter it shows win32 error.i googled it and found
Login Box appears when a button on the webpage is clicked
Login Box appears when a button on the webpage is clicked  How to create a Login Box on a web page that appears only when a button that is already present on the page is clicked
Login Box appears when a button on the webpage is clicked
Login Box appears when a button on the webpage is clicked  How to create a Login Box on a web page that appears only when a button that is already present on the page is clicked
Login Box appears when a button on the webpage is clicked
Login Box appears when a button on the webpage is clicked  How to create a Login Box on a web page that appears only when a button that is already present on the page is clicked
java how to open CD drive through code - Applet
java how to open CD drive through code  hi every one i wanted to write a code for my application using that functionality i want to be able to open... in java...can anybody tell me how to use that package in java
Open Source ERP/CRM written in Java - Java Beginners
Open Source ERP/CRM written in Java  I seek an Open Source ERP/CRM RECRUITMENT database. to integrate - candidate/client/tasks/records/ and for functionality use. Please advise
give me source code of webpage creation using html
give me source code of webpage creation using html  how to create a webpage using html
display resume content in webpage - JSP-Servlet
display resume content in webpage  Hi everbody, I have to display resume(.pdf, .doc,.rtf..txt)file content into a webpage(jsp or html). please i want help like are there any APIs available or any solution?? thank in advance
Page is not getting loaded when I refresh the webpage???
Page is not getting loaded when I refresh the webpage???  **I am loading an image section(image,demo link,Zoom) in a webpage by using javascript function in JSP. It will get all details of image section from database. *I am
How to Open Picture From M.S. Access Database using Java Servlet ?
How to Open Picture From M.S. Access Database using Java Servlet ?  ... Database But i m still not able to open this picture through Java using M.S. Access and i wants to open this Picture On Web Browser using Java Servlet anybody can
create, edit ,open simple documents using java - Swing AWT
create, edit ,open simple documents using java   In my program I have a text area.How to create document which will contain text in text... want to use Java Swing or JSP? Do you want to create word document file
Login Box appears at the background of my webpage?
Login Box appears at the background of my webpage?   As per the answer regarding my earlier query, when I post the code in my HTML page, the Login Box appears at the background of my HTMl page...........I tried CSS to change its
Open or Open Source Software
Open or Open Source Software  what is mean by open or open source software in Computer Terminology?   In a computer terminology, open or open source software means any technology or a software that are freely available
Open Text or Word Document on JButton Click in Java - Java Beginners
Open Text or Word Document on JButton Click in Java  How to open Word document or Text File on JButton Click in java  Hi Friend, Try the following code: import java.io.*; import java.util.*; import javax.swing.
hi RoseIndia why there is not Fackbook Like button on your webpage?
hi RoseIndia why there is not Fackbook Like button on your webpage?   hi RoseIndia why there is no Fackbook Like button on your webpage? That's the only prob in your problem. Others are excellent
displaying a calendar of only current month in jsp on webpage using javascript
displaying a calendar of only current month in jsp on webpage using javascript  how can we display a calendar of only current month in jsp on webpage using javascript
how to display the data from excel to webpage
how to display the data from excel to webpage  Hi, I need help on following I have a webpage contains a text box and a button(get), i give a value in text box such as serial no. like 4024 and by click on get button it should
Comparing the various Open Source Java iOS Tools
and more Open source Java tools are being made available for iOS. These tools run... the developer to run Java on iOS. Google has also provided an open source J2ObjC.... There are three categories of tools Open source Java iOS tools: The first one uses server
Advertisements
 

 

 

DMCA.com