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

📄 buttonexample.java

📁 JAVA SE6 全方位学习 朱仲杰 编著 机械工业出版社出版
💻 JAVA
字号:
import java.awt.*;import java.awt.event.*;public class ButtonExample implements ActionListener{	Frame f;	Button b1, b2;	public static void main(String argv[])	{		new ButtonExample();	}	public ButtonExample()	{		f = new Frame("Button Example");		f.setLayout(new GridLayout(1,2));		b1 = new Button("Left");		b1.setActionCommand("b1");		b1.addActionListener(this);		b2 = new Button("Right");		b2.setActionCommand("b2");		b2.addActionListener(this);		f.add(b1);		f.add(b2);		f.pack();		f.setVisible(true);	}	public void actionPerformed(ActionEvent e)	{		String cmd = e.getActionCommand();		if ( cmd.equals("b1") )			b2.setEnabled( !b2.isEnabled() );		else			b1.setEnabled( !b1.isEnabled() );	}}

⌨️ 快捷键说明

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