java编程实例,利用jbulider环境编程.
不错啊
源代码在线查看: note.java~10~
package untitled2; import java.awt.*; import java.awt.event.*; import java.applet.*; public class note extends Applet { int i=10,j=10; Color mycolor; Font myfont; String str; 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); } /**Construct the applet*/ public note() { } /**Initialize the applet*/ public void init() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } /**Component initialization*/ private void jbInit() throws Exception { this.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(KeyEvent e) { this_keyPressed(e); } }); } /**Get Applet information*/ public String getAppletInfo() { return "Applet Information"; } /**Get parameter info*/ public String[][] getParameterInfo() { return null; } void this_keyPressed(KeyEvent e) { i+=15; if(i>200){ i=10; j=j+20; } str = String.valueOf(e.getKeyChar()); repaint(); } public void paint(Graphics g){ mycolor = new Color(30,155,155); g.setColor(mycolor); myfont = new Font("TimesRoman",Font.BOLD,20); g.setFont(myfont); g.drawString(str,i,j); } public void update(Graphics g){ paint(g); } }