我使用添加到html的Applet。 但这张照片并没有表演。 没有错误消息。 什么地方出了错? 我用appletviewer来测试。 就像没有的那样。
HTMLCODE
<body>
<applet code=SS.class
archive="av.jar, httpclient-4.2.2.jar, httpcore-4.2.2.jar, commons-logging-1.1.1.jar, fluent-hc-4.2.2 httpclient-cache-4.2.2, httpmime-4.2.2"
width=719 height=679>
</applet>
</body>
</html>
我的代码很混乱 所以我只是打开他的框架 我类似的框架不应该正常运行
JAVA CODE
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.ParseException;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
public class SS extends Applet
{
/**
*
*/
public static final long serialVersionUID = 1L;
public static void main(String args[])
{
win1 bb = new win1();
}
}
class win1 extends JFrame implements ActionListener
{
JButton bt2 = new JButton("1");
JButton bt3 = new JButton("2");
JButton bt4 = new JButton("3");
JButton bt5 = new JButton("4");
JButton bt6 = new JButton("5");
JButton bt = new JButton("6");
JButton bt7 = new JButton("7");
JButton bt8 = new JButton("8");
JButton bt9 = new JButton("9");
JButton bt10 = new JButton("10");
JButton sd = new JButton("11");
JRadioButton jb1=new JRadioButton("12",true);
private JLabel Jlb_ID = new JLabel("13");
private JLabel Jlb_PW = new JLabel("14");
private JLabel txAC = new JLabel("15");
private JLabel txPW = new JLabel("16");
private JLabel Jlb_IP = new JLabel("IP");
private JTextField jpw = new JTextField(10);
private JTextField UN = new JTextField(4);
private JTextField TM = new JTextField(2);
private JTextField F4 = new JTextField(1);
private JTextField kg = new JTextField(6);
private JTextField jid = new JTextField(10);
private JTextField name = new JTextField(10);
private JTextField pass= new JTextField(10);
private JTextField ip= new JTextField(10);
public win1()
{
super("win");
setSize(100,800);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setVisible(true);
Container pn = getContentPane();
FlowLayout fy = new FlowLayout();
pn.setLayout(fy);
bt2.addActionListener(this);
bt3.addActionListener(this);
bt.addActionListener(this);
bt4.addActionListener(this);
bt5.addActionListener(this);
bt6.addActionListener(this);
bt7.addActionListener(this);
bt8.addActionListener(this);
bt9.addActionListener(this);
bt10.addActionListener(this);
sd.addActionListener(this);
jb1.addActionListener(this);
pn.add(Jlb_IP);
pn.add(ip);
pn.add(txAC);
pn.add(pass);
pn.add(txPW);
pn.add(name);
pn.add(bt2);
pn.add(Jlb_ID);
pn.add(jid);
pn.add(Jlb_PW);
pn.add(jpw);
pn.add(bt);
pn.add(UN);
pn.add(bt7);
pn.add(bt8);
pn.add(TM);
pn.add(bt9);
pn.add(bt3);
pn.add(bt4);
pn.add(bt5);
pn.add(bt6);
pn.add(F4);
pn.add(bt10);
pn.add(kg);
pn.add(sd);
pn.add(jb1);
Jlb_PW.setLocation(250,50);
Jlb_PW.setSize(100,20);
Jlb_PW.setFont(new Font("Serif",Font.BOLD,16));
txPW.setLocation(250,50);
txPW.setSize(100,20);
txPW.setFont(new Font("Serif",Font.BOLD,16));
bt2.setLocation(250,50);
bt2.setSize(100,20);
txPW.setFont(new Font("Serif",Font.BOLD,16));
txAC.setLocation(250,50);
txAC.setSize(100,20);
txAC.setFont(new Font("Serif",Font.BOLD,16));
Jlb_ID.setLocation(100,200);
Jlb_ID.setSize(100,20);
Jlb_ID.setFont(new Font("Serif",Font.BOLD,16));
jpw.setLocation(70,50);
jpw.setSize(100,20);
jpw.setToolTipText("KKKKK");
jid.setLocation(10,50);
jid.setSize(100,20);
jid.setToolTipText("KKKKKK");
name.setLocation(10,150);
name.setSize(100,20);
pass.setLocation(10,200);
pass.setSize(100,20);
ip.setLocation(10,250);
ip.setSize(100,20);
setContentPane(pn);
}
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
}
}
答案 0 :(得分:2)
我认为在public class SS extends Applet
中创建main而不是必须创建init()
方法。
public class SS extends Applet
{
/**
*
*/
public void init() {
win1 bb = new win1();
getContentPane().add(bb )
}
}
但首先,您必须了解applet How to Make Applets
的基础知识