public class helloworld extends Applet {
boolean isStandalone = false;
JLabel jLabel1 = new JLabel();
XYLayout xYLayout1 = new XYLayout();
JButton jButton1 = new JButton();
//Get a parameter value
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
} //Construct the applet
public helloworld() {
}
//Initialize the applet
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
jLabel1.setText("helloworld");
this.setLayout(xYLayout1);
jButton1.setText("jButton1");
this.add(jLabel1, new XYConstraints(155, 145, -1, -1));
this.add(jButton1, new XYConstraints(153, 119, -1, -1));
}
//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
}
//Main method
public static void main(String[] args) {
helloworld applet = new helloworld();
applet.isStandalone = true;
Frame frame;
frame = new Frame() {
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
public synchronized void setTitle(String title) {
super.setTitle(title);
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
}
};
frame.setTitle("Applet Frame");
frame.add(applet, BorderLayout.CENTER);
applet.init();
applet.start();
frame.setSize(400,320);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
frame.setVisible(true);
}
boolean isStandalone = false;
JLabel jLabel1 = new JLabel();
XYLayout xYLayout1 = new XYLayout();
JButton jButton1 = new JButton();
//Get a parameter value
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
} //Construct the applet
public helloworld() {
}
//Initialize the applet
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
jLabel1.setText("helloworld");
this.setLayout(xYLayout1);
jButton1.setText("jButton1");
this.add(jLabel1, new XYConstraints(155, 145, -1, -1));
this.add(jButton1, new XYConstraints(153, 119, -1, -1));
}
//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
}
//Main method
public static void main(String[] args) {
helloworld applet = new helloworld();
applet.isStandalone = true;
Frame frame;
frame = new Frame() {
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
public synchronized void setTitle(String title) {
super.setTitle(title);
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
}
};
frame.setTitle("Applet Frame");
frame.add(applet, BorderLayout.CENTER);
applet.init();
applet.start();
frame.setSize(400,320);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
frame.setVisible(true);
}
解决方案 »
- JTextField怎样使键盘按下的键不输出?
- 把控制台的输入,写入到文件,这样写有什么不对
- j2se类型转换问题
- TreeTable中单元格颜色设定问题
- JButton与键盘关联
- 谁能发一点SCJP 5.0 的模拟考试题目
- 程序编译通过,但执行出错,,问题如下,求高手指点,先谢谢今晚给我指出字符串数组错误的朋友们
- 网上看到的一道Java面试题,关于内部类的,大家帮忙看看。
- 在java中如何调用sql的count出来的结果
- java程序能不能生成*.exe文件
- JavaWebStart 找不到主类!大虾救命啊!!!!
- 请问:think in java 这本书中的reference到底指什么?参数or对象?
但htmconvert我也没有试过,但我知道它是可以的。
你去查找一下关键字htmconvert。
IE不支持swing,only 支持awt.
one easy way is change , JApplet--->Applet,JButton--->Button,JLabel--->Label,JXXXX--->XXXX
good luck!!