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

📄 testtextarea.java

📁 java2 primer plus一书源程序
💻 JAVA
字号:
/* * TestTextArea.java * * Created on July 30, 2002, 2:36 PM */package com.samspublishing.jpp.ch13;import java.awt.*;import java.awt.event.*;/** * * @author  Stephen Potts * @version */public class TestTextArea extends Frame implements ActionListener{   Button btnExit;   Button btnAppend;   Button btnInsert;   Button btnReplace;   TextArea taLetter;      /** Creates new TestDialog */   public TestTextArea()   {      btnAppend = new Button("Append");      btnAppend.addActionListener(this);      btnInsert = new Button("Insert");      btnInsert.addActionListener(this);      btnReplace = new Button("Replace");      btnReplace.addActionListener(this);      btnExit = new Button("Exit");      btnExit.addActionListener(this);      taLetter =                new TextArea("",10,30, TextArea.SCROLLBARS_VERTICAL_ONLY);      taLetter.append("I am writing this letter to inform you that you");      taLetter.append(" have been drafted into the United States Army.");      taLetter.append(" You will report to Fort Bragg, North Carolina ");      taLetter.append("on July 20, 1966.  You will be assigned to ");      taLetter.append("Vietnam.");                  add(btnAppend);      add(btnInsert);      add(btnReplace);      add(btnExit);      add(taLetter);      this.setLayout(new FlowLayout());           addWindowListener(new WinCloser());      setTitle("Using a TextArea Object");      setBounds( 100, 100, 400, 400);      setVisible(true);   }      public void actionPerformed(ActionEvent ae)   {      if (ae.getActionCommand().equals("Append"))         taLetter.append("\n\nSincerely, \n     The Draft Board");      if (ae.getActionCommand().equals("Insert"))         taLetter.insert("Dear Steve,\n     ", 0);      if (ae.getActionCommand().equals("Replace"))         taLetter.replaceRange("Dear Jerry,\n     ", 0, 12);      if (ae.getActionCommand().equals("Exit"))         System.exit(0);   }      public static void main(String[] args)   {      TestTextArea tta = new TestTextArea();   }   }class WinCloser extends WindowAdapter{   public void windowClosing(WindowEvent e)   {      System.exit(0);   }}

⌨️ 快捷键说明

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