import java.awt.*;
import java.applet.*;
public class MyApplet extends Applet{
/**
*
*/
private static final long serialVersionUID = 1L;
String dString = "Value is null";
String gPath="";
public void get_path(){
gPath = this.getParameter("path");
if(gPath == null)
gPath = dString;
//setBackground(Color.cyan);
}
public void paint(Graphics g){
g.drawString(gPath, 20, 30);
}
}
HTML code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title> Upload File </title>
<script type="text/javascript">
var sys_path;
function print_path(){
sys_path = document.getElementById('name').value;
document.app.get_path();
document.write(sys_path);
}
</script>
<applet code="MyApplet.class" name="app" width="300" height="200">
<param name="path" value="&{sys_path};">
</applet>
</head>
<body>
<form>
Path:<input type="text" id="name" \>
<input type="button" value="click" onClick="print_path();" />
</form>
</body>
</html>
说明:
在这些代码中,我试图从文本框中获取输入并在applet中显示。我尝试了这几天而无法找到方法。请帮我解决这个问题。提前致谢!