ch7_e7_27.java

来自「各种关于JAVA的初级编程」· Java 代码 · 共 60 行

JAVA
60
字号
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 + =
减小字号Ctrl + -
显示快捷键?