944,181 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Marked Solved
  • Views: 6537
  • Java RSS
You are currently viewing page 1 of this multi-page discussion thread
Aug 16th, 2007
0

button with hyperlink....how?

Expand Post »
I want to make: when i click a button after I've given some input it checks & if successful it opens a new window/page i.e I want to create a link....till now I've done

Java Syntax (Toggle Plain Text)
  1.  
  2. import javax.swing.JOptionPane;
  3.  
  4.  
  5. public class inputwindow {
  6.  
  7. /**
  8.   * @param args
  9.   */
  10. public static void main(String[] args) {
  11. // TODO Auto-generated method stub
  12. //String id= "admin";
  13. //String pw= "admin";
  14. String name,pass = "";
  15. name = JOptionPane.showInputDialog("UserName");
  16. pass = JOptionPane.showInputDialog("Password");
  17. //String msg = "Hello " + name ;
  18. //JOptionPane.showMessageDialog(null, msg);
  19. if (name.equals("admin") && pass.equals("admin"))
  20. {
  21. JOptionPane.showMessageDialog(null, "login successful");
  22. }
  23. else {
  24. JOptionPane.showMessageDialog(null,"you are not allowed");
  25. }
  26.  
  27. }
  28.  
  29. }


here in the place of "login successful" i want to put somthing that will open a window to be specific I want open a "xyz" web application. for eg: "http://localhost:8080/xyz"......hope I've made myself clear....please suggest..thanks
Similar Threads
Reputation Points: 10
Solved Threads: 1
Light Poster
apontutul is offline Offline
38 posts
since Nov 2006
Aug 16th, 2007
0

Re: button with hyperlink....how?

I dont think you can use hyperlink in windows application

its only for web application
Reputation Points: 119
Solved Threads: 7
Practically a Posting Shark
vinod_javas is offline Offline
871 posts
since Feb 2007
Aug 16th, 2007
0

Re: button with hyperlink....how?

Read the Swing tutorial. You are looking for ActionListener.
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006
Aug 16th, 2007
0

Re: button with hyperlink....how?

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?
Moderator
Featured Poster
Reputation Points: 3239
Solved Threads: 839
Posting Genius
Ezzaral is offline Offline
6,761 posts
since May 2007
Aug 17th, 2007
0

Re: button with hyperlink....how?

actually i want only "one person"/admin to enter a specific folder inside the application not the whole application as you said....could someone tip me some details about ActionListener....i'm bit confused!
Reputation Points: 10
Solved Threads: 1
Light Poster
apontutul is offline Offline
38 posts
since Nov 2006
Aug 18th, 2007
0

Re: button with hyperlink....how?

What don't you understand. Be more specific.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Aug 19th, 2007
0

Re: button with hyperlink....how?

I want to pass this URL
"http://localhost:8080/xyz/admin" as a parameter when the user clicks OK or enters the password in the JoptionPane.......is it possible with ActionListener.....how?

ps: how can I make both the username/password be taken from ONE dialog box? (as you can see i'm using 2boxes)
Last edited by apontutul; Aug 19th, 2007 at 7:03 am.
Reputation Points: 10
Solved Threads: 1
Light Poster
apontutul is offline Offline
38 posts
since Nov 2006
Aug 19th, 2007
0

Re: button with hyperlink....how?

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.
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006
Aug 20th, 2007
0

Re: button with hyperlink....how?

Click to Expand / Collapse  Quote originally posted by masijade ...
I assume you're letting him enter a URL.
could'nt understand what you meant by that.
the user enters id/pw (both "admin")...if he enters correctly he will be given the access to the "admin" folder of the web application. the user does'nt enters any URL!!!....is there any tool other than JoptionPane that will make matters easier?
Reputation Points: 10
Solved Threads: 1
Light Poster
apontutul is offline Offline
38 posts
since Nov 2006
Aug 20th, 2007
0

Re: button with hyperlink....how?

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.
Last edited by masijade; Aug 20th, 2007 at 4:51 am. Reason: typo
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Help Needed in JAVA Program
Next Thread in Java Forum Timeline: disabling class verifier





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC