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

📄 example4_2.java

📁 书中的例题
💻 JAVA
字号:
/* 文本组件基本功能 */
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Example4_2 extends Applet implements ActionListener
{
  TextArea txt1=new TextArea(7,35);
  TextField txt2=new TextField(35);
  String str="TextArea 可以编辑多行文本。\n"+
           "TextArea编辑和显示多行文本, \n"+
           "TextArea是显示多行文本的编辑器。";

  public void init()
  {
    txt1.setText(str);
    add(txt1);
    add(txt2);
    txt2.addActionListener(this);
  }

  public void actionPerformed(ActionEvent e)
  {
    String s;
    if (e.getSource()==txt2)
      {
        s=txt2.getText();
        txt1.append("\n"+s);
      }
   }
}

⌨️ 快捷键说明

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