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

📄 example7_24.java.bak

📁 不错的教程 适合中高级人员的使用
💻 BAK
字号:
import java.awt.*;import java.awt.event.*;
 class MyButton extends Button implements ActionListener
{  int x=10,y=10,i=0;
   Color color[]={Color.red,Color.yellow,Color.green};
   Color c=color[0];
   MyButton()
   {  
	  setSize(38,85);
	  setBackground(Color.cyan);
	  addActionListener(this);	  
   } 
   public void paint(Graphics g)
	{
	   g.setColor(c);
	   g.fillOval(x,y,20,20);           
   }
   public void update(Graphics g)
	{
	   g.clearRect(x,y,20,20);
	   paint(g);
   }
  
  public void actionPerformed(ActionEvent e)
   { i=(i+1)%3;
     c=color[i];
	 y=y+23;
	 if(y>56)
		 y=10;
	     repaint();     
   }
}
class WindowCanvas extends Frame
{
	WindowCanvas()
	{
		MyButton button=new MyButton();
		setLayout(null);
		add(button);
		button.setLocation(30,30);
		setBounds(60,125,100,200);
		setVisible(true);
	    validate();
	}
}
public class Example7_24
{
	public static void main(String args[])
	{
		new WindowCanvas();
	}
}

⌨️ 快捷键说明

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