How to get a web page to open when a button is clicked?

Discussion in 'Programming General' started by bad_moose, Sep 13, 2009.

How to get a web page to open when a button is clicked?
  1. Unread #21 - Sep 15, 2009 at 11:20 AM
  2. bad_moose
    Joined:
    Jul 31, 2008
    Posts:
    1,305
    Referrals:
    0
    Sythe Gold:
    0

    bad_moose Guru

    How to get a web page to open when a button is clicked?

  3. Unread #22 - Sep 15, 2009 at 6:03 PM
  4. super_
    Joined:
    Dec 20, 2008
    Posts:
    91
    Referrals:
    0
    Sythe Gold:
    0

    super_ Member

    How to get a web page to open when a button is clicked?

    Ugh... have you ever heard of Sun's Java API docs? Desktop.browse() takes a java.net.URI object; it appears it can't locate that symbol (*cough* import java.net.URI; *cough*).
     
  5. Unread #23 - Sep 15, 2009 at 8:45 PM
  6. SuF
    Joined:
    Jan 21, 2007
    Posts:
    14,212
    Referrals:
    28
    Sythe Gold:
    1,234
    Discord Unique ID:
    203283096668340224
    <3 n4n0 Two Factor Authentication User Community Participant Spam Forum Participant Sythe's 10th Anniversary

    SuF Legend
    Pirate Retired Global Moderator

    How to get a web page to open when a button is clicked?

    Why don't you download Eclipse. It makes life a lot easier.
     
  7. Unread #24 - Sep 15, 2009 at 8:51 PM
  8. Jimmy
    Joined:
    Jun 24, 2008
    Posts:
    2,421
    Referrals:
    10
    Sythe Gold:
    25

    Jimmy Ghost
    Retired Sectional Moderator $5 USD Donor

    How to get a web page to open when a button is clicked?

  9. Unread #25 - Sep 15, 2009 at 9:27 PM
  10. SuF
    Joined:
    Jan 21, 2007
    Posts:
    14,212
    Referrals:
    28
    Sythe Gold:
    1,234
    Discord Unique ID:
    203283096668340224
    <3 n4n0 Two Factor Authentication User Community Participant Spam Forum Participant Sythe's 10th Anniversary

    SuF Legend
    Pirate Retired Global Moderator

    How to get a web page to open when a button is clicked?

    My idea still helps. Sir.
     
  11. Unread #26 - Sep 16, 2009 at 11:22 AM
  12. bad_moose
    Joined:
    Jul 31, 2008
    Posts:
    1,305
    Referrals:
    0
    Sythe Gold:
    0

    bad_moose Guru

    How to get a web page to open when a button is clicked?

    Super, you are awesome, your idea worked, thanks very much!

    Thanks very much also to everyone else who posted, your advice really helped too ! :D
    Thanks!
     
  13. Unread #27 - Oct 3, 2009 at 6:12 PM
  14. Canownueasy
    Joined:
    Oct 3, 2009
    Posts:
    7
    Referrals:
    0
    Sythe Gold:
    0

    Canownueasy Newcomer

    How to get a web page to open when a button is clicked?

    Wow, this shows that this community knows shit.

    First make a new class with this in it. Save as WebHandler.java

    Code:
    import java.awt.Desktop;
    
    public class WebHandler {
    
        public void openWebsite() {
            if(Desktop.isDesktopSupported()) {
                try {
                    Desktop.getDesktop().browse(new URI("www.yoursite.com"));
                } catch (Exception e) {
                    System.out.println("Error upon opening webpage.");
                    e.printStackTrace();
                }
            }
        }
    }
    Now under
    Code:
    if (buttonId == 143) {
    Add this.

    Code:
    openWebsite();
    }
    And in your Client, Player, and ActionButton class.

    Add this import:

    Code:
    import WebHandler;
     
  15. Unread #28 - Oct 3, 2009 at 7:01 PM
  16. Jimmy
    Joined:
    Jun 24, 2008
    Posts:
    2,421
    Referrals:
    10
    Sythe Gold:
    25

    Jimmy Ghost
    Retired Sectional Moderator $5 USD Donor

    How to get a web page to open when a button is clicked?

    Which is pretty much what I stated, however you forgot to import java.net.URI in your WebHandler class. Also, you can't import classes in the default package like you tried to do with your "import WebHandler" statment.
     
  17. Unread #29 - Oct 3, 2009 at 7:12 PM
  18. Canownueasy
    Joined:
    Oct 3, 2009
    Posts:
    7
    Referrals:
    0
    Sythe Gold:
    0

    Canownueasy Newcomer

    How to get a web page to open when a button is clicked?

    Well if he a packaged server he would need an import. :p
     
< Java Doesn't Work | I have a question about Python >

Users viewing this thread
1 guest


 
 
Adblock breaks this site