⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fun.java~32~

📁 jbuilder 100例 java源码学习,非常不错,有需要朋友下来
💻 JAVA~32~
字号:
package joy;import java.awt.*;import java.awt.event.*;import java.applet.*;import javax.swing.*;public class fun extends Applet {  int x;  boolean flag;  boolean isStandalone = false;  JToggleButton joy = new JToggleButton();  /**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 fun() {  }  /**Initialize the applet*/  public void init() {    try {      jbInit();    }    catch(Exception e) {      e.printStackTrace();    }  }  /**Component initialization*/  private void jbInit() throws Exception {    joy.setText("joy");    joy.addActionListener(new java.awt.event.ActionListener() {      public void actionPerformed(ActionEvent e) {        joy_actionPerformed(e);      }    });    this.setBackground(Color.lightGray);    this.addKeyListener(new java.awt.event.KeyAdapter() {      public void keyPressed(KeyEvent e) {      }    });    this.add(joy, null);  }  /**Get Applet information*/  public String getAppletInfo() {    return "Applet Information";  }  /**Get parameter info*/  public String[][] getParameterInfo() {    return null;  }  void joy_actionPerformed(ActionEvent e) {   if(x==0)      flag=true;   if(flag==true)      x++;   else      x--;    repaint();    if(x==6){      flag=false;      x=0;   }  }  public void update(Graphics g){  paint(g);  g.clearRect(0,0,300,40);  }  public void paint(Graphics g){       switch(x){         case 0:            joy.setText("head");            break;          case 1:            g.drawArc(50,50,150,100,0,360);             joy.setText("eye");             break;          case 2:             g.setColor(Color.black);             g.fillOval(90,70,10,10);             g.fillOval(150,70,10,10);             joy.setText("nose");             break;           case 3:             int x[]={125,120,130};              int y[]={100,120,120};             g.setColor(Color.red);              g.fillPolygon(x,y,3);             joy.setText("mouth");             break;            case 4:            joy.setText("ear");             g.setColor(Color.yellow);             g.drawLine(110,130,140,130);             g.drawArc(110,110,30,20,180,180);            break;            case 5:             g.drawOval(40,90,10,10);             g.drawOval(190,90,10,10);                joy.setText("clear");                break;              }     }  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -