Results 1 to 2 of 2
  1. #1
    lemon3 is offline Member
    Join Date
    Jul 2008
    Rep Power

    Default launch a browser with a button

    Hi, i just started java and try to make a button that launches
    a web-browser with a predefined url... in netbeans. does anyone
    knows how to do that?
    i imported java.awt.Desktop, and tried to put some method
    in the button when it clicks.. but i dont get it to work..
    does anyone know where to put the classes and methods
    and what they should look like
    can anyone help me??
    this is my first java program btw

    thanks, and good luck

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Colombo, Sri Lanka
    Blog Entries
    Rep Power


    This is not specific to NetBeanse either.

    First you have to add a button to a container(It's your choice, you can use a JFrame, JDialo, etc.) On NetBeans adding a button is so easy.

    Then add a click even to the button. Simply double click on the already added button. You can see that auto generated click event.

    As the final step what you have to do is, execute the browser with the specified URL. This implementation already discussed few times here in our community. Search the forum.

    Good luck.

Similar Threads

  1. Launch native app inside a JFrame???
    By benedums in forum Advanced Java
    Replies: 6
    Last Post: 02-25-2011, 03:23 PM
  2. Browser
    By Jessie Madman in forum AWT / Swing
    Replies: 20
    Last Post: 02-17-2009, 01:56 PM
  3. how to get url from browser
    By srinivas reddy in forum New To Java
    Replies: 0
    Last Post: 02-08-2008, 07:46 AM
  4. launch a desktop icon program command
    By avaj987 in forum New To Java
    Replies: 3
    Last Post: 08-03-2007, 11:40 AM
  5. stop button in the browser
    By Peter in forum Java Servlet
    Replies: 2
    Last Post: 07-04-2007, 07:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts