> Top posting is a style choice I make. Why do people get so upset
> about top-posting grrr
>
> If I use a html form control how can I access the contents of the HTML
> control from my applet? You mention accessing JavaScript functions
> from an applet. Is that the way to do it? How?
> > Top posting is a style choice I make. Why do people get so upset
> > about top-posting grrr
[quoted text clipped - 14 lines]
> --
> Dag.
Is that more to your liking?
If I use a html form control how can I access the contents of the HTML
control from my applet? I had a look at accessing JavaScript functions from
an
applet but that seems fraught with problems so something I want to avoid.
Angus
Andrew Thompson - 21 Nov 2006 13:00 GMT
(JS mentioned)
...
> > > If I use a html form control how can I access the contents of the HTML
> > > control from my applet? You mention accessing JavaScript functions
> > > from an applet. Is that the way to do it? How?
..
> > Tip thou... I have posted about this Applet/JS topih here before...
..
> If I use a html form control how can I access the contents of the HTML
> control from my applet?
Can we take a pause here and get a little more
detail on the end effect you are trying to achieve?
(I am sure there is a simpler way to approach what
this web-app. needs to do, but it is not very clear to
me yet, what it's supposed to do and how.)
Note that applets are not good at interacting directly with
HTML, they do it via JS generally, so it seems either the
Java is an unnecessary overhead, or the HTML is unnecessary,
or if neither of those statements is correct, the JS is essential!
Andrew T.
Dag Sunde - 21 Nov 2006 13:15 GMT
<snipped/>
>> Tip thou... I have posted about this Applet/JS topih here before...
>
[quoted text clipped - 5 lines]
> applet but that seems fraught with problems so something I want to
> avoid.
Brilliant! ;-)
You need to add the plugin.jar to your classpath while developing
(Part of JRE, and not JDK)
Put the applet class files in the same directory as your html-file
on the server...
Here's the html:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript">
function getSelected() {
return document.getElementById("names").value;
}
</script>
</head>
<body>
<applet code=CallbackApplet.class width="300" height="50" >
</applet>
<select id="names">
<option value="Andrew" selected="selected">Andrew</option>
<option value="Angus">Angus</option>
<option value="Dag">Dag</option>
</select>
</body>
</html>
And here's the Applet code:
import java.applet.Applet;
import netscape.javascript.*;
import java.awt.*;
import java.awt.Button;
import java.awt.event.ActionEvent;
public class CallbackApplet extends Applet {
private Panel content = new Panel();
private Button cmdGet = new Button();
private Label lbl = new Label();
public void init() {
content.setBackground( Color.YELLOW);
this.add(content);
lbl.setText("Hello World!");
content.add(lbl);
cmdGet.setLabel("Get Combo Item");
cmdGet.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
getSelectedItem(e);
}
});
content.add(cmdGet);
this.invalidate();
}
private void getSelectedItem(ActionEvent e) {
JSObject appletOwner = JSObject.getWindow ( this );
lbl.setText(appletOwner.call ( "getSelected", null ).toString());
}
}

Signature
Dag.