2008年3月1日

     摘要:   阅读全文

posted @ 2008-03-01 10:42 鲁胜迪 阅读(152) | 评论 (0)编辑 收藏

使浏览器能自动下载JVM的方法

<OBJECT
classid = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
codebase = "http://java.sun.com/products/plugin/1.4/jinstall-1_4-windows-i586.cab#Version=1,4,1,0"
WIDTH = "100%" HEIGHT = "500" >
<PARAM NAME = CODE VALUE = "nz.astarte.planwise.gantt.GanttApplet" >
<PARAM NAME = CODEBASE VALUE = "." >
<PARAM NAME = ARCHIVE VALUE = "pwgantt.jar" >
<PARAM NAME = "type" VALUE = "application/x-java-applet;version=1.4">
<PARAM NAME = "scriptable" VALUE = "false">
<PARAM NAME = "projectId" VALUE="<%=theForm.getProjectId().toString()%>" >
<PARAM NAME = "userId" VALUE="<%=userId%>" >
<PARAM NAME = "logLevel" VALUE="INFO" >
<COMMENT>
<EMBED
type="application/x-java-applet;jpi-version=1.4.1"
CODE="nz.astarte.planwise.gantt.GanttApplet"
CODEBASE="."
ARCHIVE="pwgantt.jar"
WIDTH="100%"
HEIGHT="500"
projectId="<%=theForm.getProjectId().toString()%>"
userId="<%=userId%>"
logLevel="INFO"
scriptable=false
pluginspage="http://java.sun.com/j2se/1.4.1/download.html">
<NOEMBED>
Could not find a plugin supported by your browser. Please download Sun's Java Plugin 1.4.1
</noembed>
</EMBED>
</COMMENT>
</OBJECT>

posted @ 2008-03-01 10:16 鲁胜迪 阅读(313) | 评论 (1)编辑 收藏

import java.applet.Applet;
import java.awt.FlowLayout;
import java.awt.HeadlessException;

import javax.swing.JApplet;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JLabel;


public class AppletLifeCycle extends JApplet {

 public AppletLifeCycle()throws HeadlessException {
  super();
 }


 public void destroy() {
  System.out.println("Applet start() is invoked!");
 }


 public String getAppletInfo() {
  return "This is my default applet created by Eclipse";
 }


 public void init() {
  getContentPane().setLayout(new FlowLayout());
  getContentPane().add(new JLabel("Applet init() is invoked!"));
  System.out.println("Applet init() is invoked!");
 }


 public void start() {
  getContentPane().add(new JLabel("Applet start() is invoked!"));
  System.out.println("Applet start() is invoked!");
  repaint();
 }


 public void stop() {
  System.out.println("Applet stop() is invoked!");
 }
 
 
 public static void main(String []args){
//Applet程序里面有了main方法后,程序就可以像Application一样运行了。
  JApplet applet =new AppletLifeCycle();//实例化一个applet
  JFrame frame=new JFrame("AppletLifeCycle");//实例化一个顶级窗口frame
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.getContentPane().add(applet);//将applet放到顶级窗口中
  frame.setSize(200,100);
  applet.init();
  applet.start();
  frame.setVisible(true);
 }
 
 

}

posted @ 2008-03-01 09:58 鲁胜迪 阅读(158) | 评论 (0)编辑 收藏