jbuilder 100例 java源码学习,非常不错,有需要朋友下来
源代码在线查看: mov.java~25~
package moving; import java.awt.*; import java.awt.event.*; import java.applet.*; class Mov extends Thread{ public void run(){ while(true) { repaint(); try{mythread.sleep(40);} catch(InterruptedException e){} } } } public class mov extends Applet { public int i=0; public boolean flag=true; Font myfont=new Font("timsroman",Font.BOLD ,30); Color mycolor=new Color(255,255,0); Mov mythread=new Mov(); boolean isStandalone = false; /**Get a parameter value*/ public String getParameter(String key, String def) { return isStandalone ? System.getProperty(key, def) : (getParameter(key) != null ? getParameter(key) : def); } public void start(){ mythread.start(); } public void stop(){ mythread.stop(); } public void paint(Graphics g) {if (flag==true) i++; else i--; if (i==280) flag=false; if (i==0) flag=true; g.setColor(mycolor); g.setFont(myfont); g.drawString("world",i,i); } /**Construct the applet*/ public mov() { } /**Initialize the applet*/ public void init() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } /**Component initialization*/ private void jbInit() throws Exception { } /**Get Applet information*/ public String getAppletInfo() { return "Applet Information"; } /**Get parameter info*/ public String[][] getParameterInfo() { return null; } }