Open website on Button Click

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
View Answers

March 23, 2010 at 3:38 PM

Hi Friend,

Try the following code:

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

public class Browser {
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());
}
}
public static void main(String[] args) {
JFrame frame = new JFrame();
JPanel panel = new JPanel();
JButton button = new JButton("Visit Us");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
openURL("http://www.roseindia.net";); }
} );
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
panel.add(button);
frame.getContentPane().add(panel);
frame.pack();
frame.setVisible(true);
}
}
Thanks









Related Tutorials/Questions & Answers:
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
on click button php
on click button php  Function in PHP for on click button
Advertisements
passing values on button click
passing values on button click  Please help me to solve this issue.I want to pass a value assigned to button to another view upon button click in xcode
iphone button click event
iphone button click event  Hi, How to write iphone button click event? Thanks   Hi, Here the method declaration: -(IBAction) myMetod...{ NSLog(@"Button clicked"); } Thanks
jquery button click
jquery button click  jquery button click - I have created a button in JQuery but the problem is that it's not detecting click. What could... to create a button event in JQuery. You can edit it as per your requirement. In Header
java swing button click event
java swing button click event  java swing button click event   public void doClick()   Java Swing Tutorials
JFrame Button click to start play
JFrame Button click to start play  i made a game and and i add a button in new jframe and i want when i click it it start to play...can anyone help me
How to call java method on Button click in jsp?
How to call java method on Button click in jsp?  How to call java method on Button click in jsp
Draw a line in a JPanel with button click in Java
Draw a line in a JPanel with button click in Java  Draw a line in a JPanel with button click in Java
On Click on Submit Button Display Data on Orderlist
On Click on Submit Button Display Data on Orderlist  How can retreive data from database on orderlist on Click on submit Button of same page
executing multiple sql statements on the single button click...
executing multiple sql statements on the single button click...  how can i frame a code on the click of a button to insert data into a table as well as to retrieve records from the same table in another form
executing multiple sql statements on the single button click...
executing multiple sql statements on the single button click...  how can i frame a code on the click of a button to insert data into a table as well as to retrieve records from the same table in another form
click on back button go to the login page
click on back button go to the login page  now when i click on back button the page show that page on where i came from and it shows the session expired but i want when i click a back buttob then it should show a login page
JSP view detail page on accept button click
JSP view detail page on accept button click  i Have 1 jsp page in that there r 2 button accept and view details when we click on aceept button it will submit to next page and when click on view details page it will shown the data
Click On Images of Submit Button Perform Action
Click On Images of Submit Button Perform Action  I have login page in which insert of submit button i used image. Therefor on Click of image i have to validate form , link with database and goto the next page
print form information when click on print button
print form information when click on print button   Sir,I desingn institute webside using jsp and strut by using platform netbean 7.2.So request you please help for printing form information by clickin print button after submit
Browser Back Button click event javascript
Browser Back Button click event javascript  I am using the below code but window.onBeforeUnload is not working with back button.. how can i apply the below code for the click event of back button? window.onBeforeUnload
iPhone Button Click Sound
iPhone Button Click Sound In this series of iPhone button tutorial, we... the application to listen the sound on button click. The sound file that i have used... on clicking the button in iPhone SDK. For the audio we are going to use
get a radio button click value - JSP-Servlet
get a radio button click value  thanks sir for sending code ,but i have one probs that is i m getting a null value i m calling getParameter("id") in servlet that is used in another jsp so can i call getParameter("radio") i.e
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
SaveAs Dialogue box is not working on button click in servlet
SaveAs Dialogue box is not working on button click in servlet  Hii Sir, i added response.setHeader into my servlet code to export the data into excel file but this is not working on button click ...plz give me
cannot open .jar files by double click
cannot open .jar files by double click  I'm having a problem i create a .jar file in net beans and yesterday it work right b y and double click but i... jre6 and jdk install in my computer i have change open with to javaw.exe
Expand / Collapse form div when click on button
Expand / Collapse form div when click on button  Hi, I have a form integrated from Wufoo with iFrame code. If the user misses a field an error message appears but it takes more space than the DIV Formbox. How can I make the DIV
change database values when click next button on jsp page
change database values when click next button on jsp page  How to retrive database values rondomly and display jsp page ,when user click next and previous bottons change the values on jsp page
Moving Div by button click using animate effect
Moving Div by button click using animate effect In this tutorial , we will discuss how to move 'div' left-right by button click using jQuery. In this example , 'div' is moving left / right by left / right button click
Open a URLConnection to specific website address
Open a URLConnection to specific website address       Here we are going to establish a connection to a specific web address via a complete example. In the example we
when i hit enter it represent action like click a button
when i hit enter it represent action like click a button  Hi, Plz provide a program in html like I want 2 submit buttons,when i hit the enter button it will represent the action like click the 1st submit
Is there any website available to open .mdb file online?
Is there any website available to open .mdb file online?  I am having an .mdb file. And I don't have MS Office in my computer. So for, I need to view the .mdb file in online. Could you tell me any website
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
Open a .doc file by click on the link using struts - Struts
Open a .doc file by click on the link using struts   I want to open a doc extension file when i click a link on jsp page .I know only about which is write in web.xml but not exactly know how i do this.Plz any one can help me
ModuleNotFoundError: No module named 'odoo12-addon-website-snippet-big-button'
ModuleNotFoundError: No module named 'odoo12-addon-website-snippet-big-button...: ModuleNotFoundError: No module named 'odoo12-addon-website-snippet-big-button' How...-website-snippet-big-button After the installation of odoo12-addon-website
ModuleNotFoundError: No module named 'odoo8-addon-website-snippet-big-button'
ModuleNotFoundError: No module named 'odoo8-addon-website-snippet-big-button...: ModuleNotFoundError: No module named 'odoo8-addon-website-snippet-big-button' How...-snippet-big-button python with following command: pip install odoo8-addon-website
ModuleNotFoundError: No module named 'odoo9-addon-website-snippet-big-button'
ModuleNotFoundError: No module named 'odoo9-addon-website-snippet-big-button...: ModuleNotFoundError: No module named 'odoo9-addon-website-snippet-big-button' How...-snippet-big-button python with following command: pip install odoo9-addon-website
display uiactivityindicatorview on button click through notification ios 5
display uiactivityindicatorview on button click through notification ios 5  I wants to add a UIActivity Indicator view on UIView controller. Also i want to display a Activity indicator when a UIButton is click. I searched
How to check for Empty textboxed and fill it with a value on a button click
with a Button beside it . when i enter a text in that box and click the button it should go.... the button should be disabled once i click it(i managed to do that), but when i'm... click. When you enter a text in a textbox and click the button, it will get added
On selecting a radio button, it should open a jsp page.
On selecting a radio button, it should open a jsp page.  Hi, COuld you please tell me how to link a radio button selection to a jsp. My requirement is if I select a radio button then it should open a jsp page. thank you
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.
How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST
How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST  How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST,please send answer as soo as possible
How to hide and show some field on a radio button click
How to hide and show some field on a radio button click  This is my... and cheque number label and textbox to be invisible when by cash radio button is clicked.and they should be visible when by cheque radio button is clicked. I have
JFrame Close On Button Click
JFrame Close On Button Click In this section we will discuss about how to close frame on click on the button. This example explains you how a frame can... on the button on a frame. In this example we will use the dispose() method to close
i want to create an application with only a button which on click displays table from database using struts2 and hibernate on eclipse
i want to create an application with only a button which on click displays table from database using struts2 and hibernate on eclipse  please help me i have to submit this soon
Hide/Show paragraph by button click
Hide/Show paragraph by button click In this tutorial, we will discuss about... example, button click event generate action of hiding paragraph and it also displays another button "click to show paragraph " .when we click
insertin form data into databse and blank all form field when click on submit button
database when click on submit button and blank all form field after inserting...insertin form data into databse and blank all form field when click on submit... for creating DSN connection: Open Data Sources (Start->Control Panel->
when radio button is selected corresponding jsp page should open
when radio button is selected corresponding jsp page should open  how to write code in HTML & jsp, when we click on radio buttons the corresponding jsp page should open..!   <html> <script> function
Show text by button click using jQuery
Show text by button click using jQuery In this tutorial, we will discuss about hide/show text by clicking on button. In the below example, there are two buttons : hide and show .The "hide " button is used to hide text
How to show next question from database on the click of next button..(Struts & Hibernate)
How to show next question from database on the click of next button..(Struts.... Problem.: When m clicking my next button it is not showing another question...?pageName=2&iid=<%=Id%>"><img src="images/edit-icon.png" title="Click
How to show next question from database on the click of next button..(Struts & Hibernate)
How to show next question from database on the click of next button..(Struts.... Problem.: When m clicking my next button it is not showing another question...="images/edit-icon.png" title="Click Here To Update This Lists" alt="Click Here
How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST
How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST  In this code how i will use arraylist(which store all my records in index form) to show next data on button click,so that it will goes
How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST
How to Display next Record from Database "On the Click of Next Button" USING ARRAYLIST  In this code how i will use arraylist(which store all my records in index form) to show next data on button click,so that it will goes
website
website  i have uploaded website .website is woking properly in chrome & firefox but not in IE

Ads