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

📄 example7_17.java

📁 不错的教程 适合中高级人员的使用
💻 JAVA
字号:
 import java.awt.*;
 import java.awt.event.*;
 class WindowNull extends Frame 
{  
   WindowNull()
   {  setLayout(null);
      MyButton button=new MyButton();
	  Panel p=new Panel();
	  p.setLayout(null);
	  p.setBackground(Color.cyan);
	  p.add(button);
	  button.setBounds(20,15,25,70);
	  add(p);
	  p.setBounds(50,50,90,100);	  
	  setBounds(120,125,250,150);
	  setVisible(true);
	  validate();
   }
}
class MyButton extends Button implements ActionListener
{
	int n=-1;
	MyButton()
	{
		addActionListener(this);
	}
	public void paint(Graphics g)
	{
		g.drawString("单",6,16);
		g.drawString("击",6,36);
		g.drawString("我",6,56);
	}
	public void actionPerformed(ActionEvent e)
	{
		n=(n+1)%3;
		if(n==0)
			setBackground(Color.red);
		else if(n==1)
			setBackground(Color.yellow);
		else if(n==2)
			setBackground(Color.green);

	}
}
public class Example7_17 
{
	public static  void main(String args[])
	{
		new WindowNull();
	}
}

⌨️ 快捷键说明

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