• Log in or sign up for an account here: https://www.sythe.org/login

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*).
 
<3 n4n0
Discord Verified
Two Factor Authentication User
Community Participant
Spam Forum Participant
Sythe's 10th Anniversary
Sythe Awards 2011 Winner
Why don't you download Eclipse. It makes life a lot easier.
 
<3 n4n0
Discord Verified
Two Factor Authentication User
Community Participant
Spam Forum Participant
Sythe's 10th Anniversary
Sythe Awards 2011 Winner
My idea still helps. Sir.
 
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*).

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!
 
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;
 
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;
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.
 
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.

Well if he a packaged server he would need an import. :p
 
Runescape Gamblingrunescape gambling
Back
Top