This message was edited by zibadian at 2007-4-24 23:41:10
: : : hi, please help me, does anybody know how to open a new window using java?
: : :
: : : the program that i would like to make would be like this, there are three text boxes with three command buttons.
: : :
: : : while the program is running, i can type the link into these three text boxes, for example, in textbox1 i type: www.programmersheaven.com, in the second textbox i type: www.yahoo.com, and in the third one i type: www.google.com, while i press the first button, the program would open a new window, and go to the link "www.programmersheaven.com", and if i press the second command button, it would go to www.yahoo.com in a new window..
: : :
: : : Thank you for your time on reading my question and answer it, i am waiting for your reply..
: : :
: : : Best Regards,
: : : Zhi Yi
: : :
: : If you want to open a new window from an applet, you can use the ApplectContext.showDocument() method (http://java.sun.com/j2se/1.5.0/docs/api/java/applet/AppletContext.html).
: : If you want to open a browser from an application, see this reference: http://www.javaworld.com/javaworld/javatips/jw-javatip66.html
: : If you want to open a new Java window in your application, you should use JFrame, since Swing components can handle html natively. I don't know if that includes images or if there is a class which can mimic a browser window.
: Thank You Zibadian..
: Now, let say that I have open a new web page, for example www.yahoo.com, now, if I want to send data (username and password) to the textbox in the web page, how to program it in java?
: So, when we run the program, there are two blank textboxes in our program, one is for username, and another one is for the password, and a command button. First, the user would would fill the username and password, and when the user press the command button, the program would open www.yahoo.com, and send the username and password from the program to the web page.. Thank You.
: Best Regards,
: Zhi Yi
With an applet this is not possible I think, unless you grant the appropriate rights to the applet. If you've granted those rights you can use the method of the application.
If the window isn't part of the application, you might be able to simulate keypresses from your application to the focused window. I don't know how to code this in Java, but perhaps you can find that code on the web.
An alternative is not to open a new window with the login page, but find out what happens when the user presses the "submit"-button. Once you know that, you can directly submit the password and username from your program and open a new window with the submitted information. This bypasses the need to place values in the webform.