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

📄 tenbuttonframe.java

📁 botton creat,more beautiful scene
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class TenButtonFrame extends JFrame implements ActionListener
{
 JButton [] button=new JButton[10];
 JButton greenButton;
 boolean s1,s2,s3;
 Container contentPane;
 public TenButtonFrame(String title)
 {
    setTitle(title);
	 setSize(400,200);
	 contentPane =getContentPane();
	 contentPane.setLayout(new FlowLayout());
	 
	 for(int i=0;i<10;i++)
	 {
	 button[i]=new JButton(i+"");
	 button[i].addActionListener(this);
	 contentPane.add(button[i]);
    }
	 	 	 
	 setDefaultCloseOperation(EXIT_ON_CLOSE);
	 }
	public void actionPerformed(ActionEvent evt)
	{

	if(evt.getSource()==button[7])
   {
	      s1=true;
	}
	else
	 {
	 contentPane.setBackground(Color.RED);
	}		  
	if(evt.getSource()==button[3])
	{
	      s2=true;    
			s1=s2=true;    
			
   }  
	 else
	{ 
	 contentPane.setBackground(Color.RED);      	
	}
	if(evt.getSource()==button[5])   
	{
	      s1=true;    
			s2=true;
			s3=true;
	} 
	 else
	{ 
	 contentPane.setBackground(Color.RED);
	}		    
      	
	}	
	public static void main(String[]args)
	{
    TenButtonFrame frame = new TenButtonFrame("Ten Button Frame");
	 frame.setVisible(true);
	 }
	}

⌨️ 快捷键说明

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