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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

form data from java applet

Status
Not open for further replies.

B2d

Programmer
Feb 4, 2002
12
0
0
NL
Hi there,

I saw an example of how to get form data to a Java applet. But how do I get it the other way around? Push a button, read data from an applet and show it in a standard HTML form (like textarea or something)

The code to write form data to a Java applet can be found here: thread269-2280 Can somebody modify it for me, so that I can get data from a applet to a form?

I tried to do it myself, but I just don't get it [sadeyes]
B2d
---
FormDataToApplet.html:
**********************
<FORM onSubmit=&quot;return false&quot;>
Please, give your name:
<INPUT TYPE=&quot;text&quot; NAME=&quot;yourname&quot; SIZE=40>
<INPUT TYPE=&quot;submit&quot; value=&quot;Pass data&quot; onClick=&quot;
document.FD.writeName(yourname.value);&quot;>
</FORM>
<HR>
<APPLET CODE=FormDataToApplet.class NAME=FD height=100 width=200>
</APPLET>

FormDataToHtml.java:
********************
import java.applet.Applet;
import java.awt.*;

public class FormDataToApplet extends Applet {
String name;

public void init() {
setBackground(Color.green);
}

public void paint(Graphics g) {
if (name!=null) {
g.setColor(Color.red);
g.drawString(&quot;Hi, &quot;+name, 10, 10);
}
}

public void writeName(String s) {
name=s;
repaint();
}
}

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top