Could someone please tell me how to hyperlink to a page? Say if I had a combobox and the user selected an item, how could I hyperlink to a page?
Printable View
Could someone please tell me how to hyperlink to a page? Say if I had a combobox and the user selected an item, how could I hyperlink to a page?
I guess just store the Strings within the JComboBox in URL format. Then when an ActionEvent is fired off from clicking on one get the value, create a new URL and go from there.
But how do you actually open a page when you have the URL object?
Well, if you have an embedded browser, you can give it the URL. But you probably want to open it externally, right?
That's a rather troublesome problem, because Java has no native support for that. What you basically need is a JNI component that figures out the user's default browser in a platform-specific way, then use System.exec to call that browser, passing the URL as a parameter.
Too bad he couldn't just integrate a brower into his app using a JEditorPane.
That HTML engine is hopelessly outdated, so I'd recommend against it.
Thanks guys, but I'm just gonna have to scrap the idea. I searched every inch of google and found nothing. Several instances allow you to use other components, but not one that I'm using. This is on an applet so I think I'll just use a little side html to create a few links using anchor tags. Anyways, thanks for helping out...sorry we coudln't find an end to this.
Oh, you're talking about applets!
Then it's simple. If 'this' is the Applet-derived class, you simply do:
this.getAppletContext().showDocument(newUrl);
So in order to create hyperlinks, you need text controls that react to clicks by doing the above.
Jesus i wish you told us you were working with Applets from the begining. :lol:
ewwwwww that did it!!!! Thank you sooo much for your help guys, this was a three day head banging against wall problem for me.
Dillenger, all you had to do was ask :rolleyes:
:lol: :lol:
Quote:
Originally Posted by Dilenger4
Hehehe...me too. I was looking in all My java books for a solution, and jumped over all Applets chapters...:D..
I knew it was an applet and had searched google for endless hours, but was making things too hard!
Applets have a very limited API, the best place to look is the java.applet package in the official docs.