multievent1.java

来自「该原代码为<Java编程基础、应用与实例>的附盘代码」· Java 代码 · 共 28 行

JAVA
28
字号
import java.awt.*;
import java.awt.event.*;
public class MultiEvent1 extends Frame implements ActionListener, TextListener{
  Label action=new Label();
  Label text=new Label();
  TextField tf=new TextField(20);
  public MultiEvent1(String title){
  	super(title);
  	action.setBackground(Color.GREEN);
  	text.setBackground(Color.PINK);
  	add(action,"North");
  	add(text,"Center");
  	add(tf,"South");
  	tf.addActionListener(this);
  	tf.addTextListener(this);
  }
  public void actionPerformed(ActionEvent e){
  	action.setText(tf.getText());
  }
  public void textValueChanged(TextEvent e){
  	text.setText(tf.getText());
  } 
  public static void main(String[] args){
    Frame f=new MultiEvent1("促吝 捞亥飘 贸府");
    f.pack();
    f.setVisible(true);    
  }
}

⌨️ 快捷键说明

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