/* * File: TextAreaTest.java * * Create an noneditable text area * * Copyright: Northeast Parallel Architectures Center * */ import java.awt.TextArea; import java.awt.Font; public class TextAreaTest extends java.applet.Applet { // use the textarea to display some text private TextArea verse; private Font f = new Font ("Dialog", Font.BOLD, 18); public void init() { setBackground( java.awt.Color.white ); setFont (f); String str = "Once upon a midnight dreary, while I pondered, weak and weary,\n" + "Over many a quaint and curious volume of forgotten lore,\n" + "While I nodded, nearly napping, suddenly there came a tapping,\n" + "As of some one gently rapping, rapping at my chamber door.\n" + "\"'Tis some visitor,\" I muttered, \"tapping at my chamber door-\n" + "Only this, and nothing more.\"\n\n" + "Ah, distinctly I remember it was in the bleak December,\n" + "And each separate dying ember wrought its ghost upon the floor.\n" + "Eagerly I wished the morrow;- vainly I had sought to borrow\n" + "From my books surcease of sorrow- sorrow for the lost Lenore-\n" + "For the rare and radiant maiden whom the angels name Lenore-\n" + "Nameless here for evermore."; // initial text, height in lines, width in characters, scrollbar visibility verse = new TextArea( str, 8, 45, TextArea.SCROLLBARS_VERTICAL_ONLY ); verse.setEditable( false ); add(verse); } }