作者poyong (打造第三把钥匙)
看板java
标题[问题] 请问一下application转applet的问题(用JBuilderX写)
时间Sun Oct 7 01:39:44 2007
台风夜请教一个问题^^
想请教如何把application改成applet (在JBuilderX下)
在不考虑其applet的安全性下 只是单纯想把application改成applet...
之前有请教过Ps大大 他说下次把题目po上来@@
(但我觉得我的题目很浅 所以那时候不太敢po...)
我用的方法是很笨的方法 就是将application的架构 一段一段贴到applet上
然後在去debug
以下我copy好的applet架构
package testi; //第二版
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
public class SimpleApplet extends Applet {
//程式码
//Construct the applet
public SimpleApplet() {
}
//Initialize the applet
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Main method
public static void main(String[] args) {
SimpleApplet applet = new SimpleApplet();
//applet.isStandalone = true;
Frame frame;
frame = new Frame();
frame.setTitle("SimpleApplet 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);
}
// Start the applet
public void start() {
}
//Stop the applet
public void stop() {
}
//Destroy the applet
public void destroy() {
}
//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
}
private void jbInit() throws Exception {
//程式码片段
JPanel contentPane;//内容的介面
contentPane = (JPanel) this.getContentPane();
//complie出现错误 can't resolvee getContentPane()
contentPane.setLayout(null);
contentPane.setBackground(Color.lightGray);
contentPane.setMaximumSize(new Dimension(32767, 32767));
contentPane.setPreferredSize(new Dimension(1, 1));
//程式码片段
}
//程式码片段
}//end of class SimpleApplet
applet的架构大概是这样 其中比较有不一样的就是上面的部份
其他//程式码片段几乎都是跟application一样的
我applet改完之後 发生一些logic error
也就是他的结果compile完是那种一开始初使的画面
跟我applicaiton执行的画面是不一样的
之前有请教过Ps大大 他跟我说要去查java API 但是我不太会查
想请问一下接下来要怎麽着手呢?
不好意思请各位大大教我一下 感谢感谢大家
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 122.123.139.19
※ 编辑: poyong 来自: 122.123.139.19 (10/07 01:41)
※ 编辑: poyong 来自: 122.123.139.19 (10/07 01:41)