📄 ch7_e7_27.java
字号:
import java.awt.*;
import java.awt.event.*;
public class ch7_e7_27
{
public static void main(String args[])
{
new MyFrame();
}
}
class MyFrame extends Frame
implements ActionListener, WindowListener
{
Label outputLbl = new Label(" ");
TextField inputTfd = new TextField(10);
Button copyBtn = new Button("复制");
MyFrame()
{
super("我的窗口");
inputTfd.setText(" ");
outputLbl.setText(" ");
setLayout(new FlowLayout());
add(inputTfd);
add(copyBtn);
add(outputLbl);
copyBtn.addActionListener(this);
addWindowListener(this);
//setSize(300,200);
//setVisible(true);
pack();
show();
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource() == copyBtn)
{
outputLbl.setText(inputTfd.getText());
}
}
public void windowClosing(WindowEvent we)
{
dispose();
System.exit(0);
}
public void windowActivated(WindowEvent we){}
public void windowClosed(WindowEvent we){}
public void windowDeactivated(WindowEvent we){}
public void windowOpened(WindowEvent we){}
public void windowIconified(WindowEvent we){}
public void windowDeiconified(WindowEvent we){}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -