Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with java button

Status
Not open for further replies.

HubCapped

Programmer
Feb 8, 2005
4
GB
Im not sure if htis is the right forum, so i'll apologise in advance;
Basically, i have an html page, i have created a html form containing a text box which takes a url and a button which passes this url to an applet (on the same page) and then displays this url on the applet.
Currently this is all my applet does-display the URL from the form ,however i have added a button to the applet and i want to be able to click on this button and open the URL in the same window.
Does anyone know how to do this?

This is my code do far:

HTML:
<form name="f1">
<b>Enter a website:p>
<input type="text" size="50" name="inurl">
<input type="button" value="Request URL" id="suburl" onClick="return validurl();">
</form>

<applet codebase="." code="javacode.class"
<param name="inurl" value="">
</applet>



JAVA:
public class javacode extends Applet
{
private Button clickButton;
String URL;

public void init()
{
URL = getParameter("inurl");

clickButton = new Button("Show URL");

}


public void updateURL(String newURL)
{
URL = newURL;
repaint();
}

public void paint(Graphics g)
{
g.drawString(URL,50 ,50);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top