怎样把这个JAVA变成JAVA Applet,可以放到网页中的那种

来源:百度知道 编辑:UC知道 时间:2024/06/22 06:35:48
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.lang.Math;

public class BargainAgent extends JFrame
{
private JLabel bpriceL,spriceL,timesL,lastsL;
private JTextField bpriceTF,spriceTF,timesTF,lastsTF;
private JButton bargainB,okayB,exitB;
private static final int WIDTH=400;
private static final int HEIGTH=300;//这里是创建GUI图形

public BargainAgent()
{
bpriceL=new JLabel("请输入你还的价格:",SwingConstants.RIGHT);
spriceL=new JLabel("agent报价:",SwingConstants.RIGHT);
timesL=new JLabel("议价次数:",SwingConstants.RIGHT);
lastsL=new JLabel("您的上次出价:",SwingConstants.RIGHT);

bpriceTF=new JTextField(10);
spriceTF=new JTextField(10);
timesTF=new JTextField(10);
lastsTF=new JTextField(10);

bargainB=new JButton("议价");
okayB=new JButton("接受议价");
exitB=new JButton("拒绝议价&

public claas MyApplet extend Applet
{
放程序,主要在方法paint()中
}
在网页<body>中
<applet code = "包名.MyApplet" height=......>
<param name=....value = ...>//传参
</applet>

建议先了解一下Applet的生命周期,然后把swt的东东搬上去就好了.

出错了贴出来.
偶好久没弄个applet.都忘光了.

首先你应该继承的是JAPPLET 或者是APPLET,而不是你现在的JFRAME

边也讲了怎样修改,有什么init(),paint(),destory()等,但操作起来老出错,现在时间又紧,这个该