📄 button2b.java
字号:
// <applet code=Button2b width=200 height=75>
// </applet>
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Button2b extends JApplet {
JButton
b1 = new JButton("Button 1"),
b2 = new JButton("Button 2");
JTextField txt = new JTextField(10);
public void init() {
b1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){
String name = ((JButton)e.getSource()).getText();
txt.setText(name);
}
});
b2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){
String name = ((JButton)e.getSource()).getText();
txt.setText(name);
}
});
Container cp = getContentPane();
cp.setLayout(new FlowLayout());
cp.add(b1);
cp.add(b2);
cp.add(txt);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -