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

📄 actiondemo.java

📁 学习参考,java基本语法练习,包括一些常用的技巧
💻 JAVA
字号:
//动作事件演示程序
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ActionDemo extends JFrame implements ActionListener
{
	JButton b1,b2;
	JPanel p1;
	JLabel l1;
	public ActionDemo()
	{
		p1=new JPanel();
		b1=new JButton("消失");
		b1.addActionListener (this);
		b2=new JButton("锁定");
		b2.addActionListener (this);
		l1=new JLabel("");
		setContentPane(p1);
		p1.add(b1);
		p1.add(b2);
		p1.add(l1);
		setSize(300,200);
		setTitle("动作事件演示");
		setVisible(true);
	}
	public void actionPerformed(ActionEvent ae)
	{
		if (ae.getSource()==b1)
			{
				b1.setVisible (false);
				l1.setText("按钮1不可见!");
			}
			
		if (ae.getSource()==b2)
			{
				b2.setEnabled(false);
				l1.setText("按钮2不可用!");
			}
	}
	public static void main(String []args)
	{
		ActionDemo ad=new ActionDemo();
	}
}

⌨️ 快捷键说明

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