I dont think you can use hyperlink in windows application
its only for web application
vinod_javas
Practically a Posting Shark
871 posts since Feb 2007
Reputation Points: 119
Solved Threads: 7
Read the Swing tutorial. You are looking for ActionListener.
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
As masijade said, you can do that with an ActionListener, however I have to wonder why you are writing a Java program just for a login and then opening a web application. Why not simply login in to the web application?
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
What don't you understand. Be more specific.
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
Read the API for JOptionPane. I assume you're letting him enter a URL, in that case you already have the URL, you simply need to capture the return value of the JOptionPane method. As I said, read the API for that (and the tutorial), it explains it completely.
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
What do you mean "you want to pass it as a parameter". Explain, without reference to URLs, JOptionPanes, Parameter Passing, or anything else technical, what it is, exactly that you want to accomplish.
masijade
Industrious Poster
4,253 posts since Feb 2006
Reputation Points: 1,471
Solved Threads: 494
If you want to have both input fields on a single panel with one Ok button, you have two options:
- Create a standard JFrame/JPanel UI form with your fields and button and put the code that processes login and opens the browser in the ActionListener (or a small Action class).
- Create a custom dialog by extending JDialog and returning whether login was successful as the dialog result and opening your browser based on the result.
The JFrame is probably the easier and more conventional option, but there are a lot of ways to skin a cat in Java.
If you are using Java 6, this method will allow you to open a url in the default browser:
http://java.sun.com/javase/6/docs/api/java/awt/Desktop.html#browse(java.net.URI )
If not Java 6, then http://www.centerkey.com/java/browser/ may be of use.
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847