ºìÁªLinuxÃÅ»§
Linux°ïÖú

Õ⼸ÌìѧÁ˵ãJAVA,½Ó×ÅתÏòJ2ME

·¢²¼Ê±¼ä:2006-10-30 00:45:35À´Ô´:ºìÁª×÷Õß:nxfte
¡¡¡¡Ç°¼¸Ìì¿´ÁËһЩJ2MEµÄÊ飬ÿ±¾Ê鶼¼ÙÉèÄãÓÐJavaµÄ»ù´¡£¬ÓôÃÆ£¬ÎÒ¸ù±¾Ã»½Ó´¥¹ý£¬Õ⼸ÌìÔÚѧϰJavaµÄһЩ¶«Î÷£¬¸Õ¿ªÊ¼¾õµÃ±È½ÏÀ§ÄÑ£¬Ñ§Á˼¸ÌìÈëÃźó·¢ÏÖ½øÕ¹ºÜ¿ì£¬Ò²Á˽âÁËһЩjavaµÄÔËÐлúÖÆ£¬ÕæÕýÀí½âÁËʲô½ÐÃæÏò¶ÔÏó£¬ËäÈ»ÒÔǰѧ¹ýc++µ«ÊÇÕæÕýÃæÏò¶ÔÏóµÄ¶«Î÷¸ù±¾Ã»×ö¹ý£¬ÒÔÇ°¶¼ÊÇÃæÏò¹ý³ÌµÄ£¬·¢ÏÖÃæÏò¶ÔÏóÔÚ½â¾ö´óÎÊÌâÉÏ»¹ÊǺÜÓÐÓÅÊƵģ¬ÌرðÊÇÔÚͼÐη½Ãæ¡£

¡¡¡¡½ÓמÍÒª¿ªÊ¼Ñ§Ï°J2MEÁË£¬²»¹ýÊ鶼ÊÇEÎĵģ¬¿´À´ÓÖҪӲͷƤ¿´ÁË¡£

¡¡¡¡²Î¼ÓÁËѧУµÄÈí¼þÉè¼Æ´óÈü£¬×¼±¸ÓÃJ2ME×öÒ»¸ö»ùÓÚÒƶ¯Æ½Ì¨µÄÈí¼þ£¬½ØÖÁµ½12Ô·ݣ¬¿ÉÒª¼Ó½ôѧϰÁË¡£

¡¡¡¡ÏÂÃæÊÇдµÄÒ»¸öºÜ¼òµ¥µÄjava³ÌÐò£¬ÓÐ×¢ÊÍ¡£

package myprojects.example;

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

class ButtonPanel extends JPanel implements ActionListener//˵Ã÷´ËÀàΪ¼àÌýÆ÷Àà

{
private JButton bt;
private String szEvtSource;

public ButtonPanel()//Panel¹¹Ô캯Êý

{
bt = new JButton ("Hello");//¶¨Òå°´Å¥

add (bt);//ÔÚPanelÉϼÓÕâ¸ö°´Å¥

bt.addActionListener(this);//Ö¸¶¨¼àÌýÆ÷¶ÔÏóΪJPanel

}

public void actionPerformed(ActionEvent evt)//µ±ÓÐʼþÏìӦʱִÐÐÏÂÃæ´úÂë

{
Object src = evt.getSource();//µÃµ½Ê¼þÔ´¶ÔÏó

if (src.equals(bt))//Èç¹ûÊÇ°´Å¥µÄʼþ

{
szEvtSource = "Hello";
}
Graphics g = getGraphics();//µÃµ½µ±Ç°Í¼ÐÎÉÏÏÂÎÄ

draw(g);//µ÷Óô«Öµ

}

public void draw(Graphics g)
{
String szMsg;
szMsg = "You've pressed me--" + szEvtSource;
g.drawString(szMsg,20,60);//Ö¸¶¨Î»ÖÃÊä³öÒ»¸ö×Ö·û´®

}
}

class ButtonFrame extends JFrame
{
public ButtonFrame()//Frame¹¹Ô캯Êý

{
setLocation(100,100);//ÉèÖóõʼλÖÃ

setSize(300,200); //ÉèÖÃFrame´óС

setTitle ("My action");//ÉèÖñêÌâ


Container ctPane = getContentPane();//µÃµ½µ±Ç°ÈÝÆ÷

ctPane.add(new ButtonPanel());//ÔÚµ±Ç°ÈÝÆ÷Àï¼ÓÒ»¸ö²ã

}
}

class Example
{
public static void main(String[] args)//³ÌÐòÈë¿Ú´¦

{
ButtonFrame a = new ButtonFrame();//½¨Á¢Ò»¸öFrame¶ÔÏó

a.setVisible(true); //ÉèÖÃΪ¿É¼û

}
}
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 6 ÌõÆÀÂÛ

  1. ph_degrees ÓÚ 2007-03-09 12:42:28·¢±í:

    :0L JAVA

  2. honglianuser ÓÚ 2007-02-28 15:18:37·¢±í:

    :0L :0L :0L

  3. Ã÷ÔÂËɼäÕÕ ÓÚ 2007-02-27 08:31:42·¢±í:

    ÎÒÒ²ÔÚŬÁ¦Ñ§JAVAÖС£¡£¡£¡£

  4. qingqingfeiyang ÓÚ 2007-02-07 17:57:46·¢±í:

    ÏÖÔÚÕâ·½ÃæµÄÊéºÜ¶à£¬Äã¿ÉÒÔÈ¥Êé³Ç¿´Ò»Ï£¬ÕÒһЩÓйØÊé¼®£¬Ñ§Ï°ÆðÀ´»áÈÝÒ×Ðí¶à£¡¡«

  5. xihaha ÓÚ 2006-10-30 21:59:14·¢±í:

    »¹ÊDz»´íµÄ

  6. zhqs ÓÚ 2006-10-30 10:54:13·¢±í:

    ´ó¼ÒÒ»ÆðŬÁ¦°É!