/** * Classe JanelaBasica - implementa uma janela onde há uma área de texto * * @author Marcelo Cohen * @version 24/03/2001 */ import javax.swing.*; import java.awt.*; import java.awt.event.*; public class JanelaBasica { // instance variables - replace the example below with your own private JTextArea texto; private JFrame frame; /** * Constructor for objects of class JanelaBasica */ public JanelaBasica(String tit) { // initialise instance variables frame = new JFrame(tit); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } } ); Container c = frame.getContentPane(); c.setLayout(new BoxLayout(c,BoxLayout.Y_AXIS)); texto = new JTextArea(30,40); //int larg = 12; //texto.getColumnWidth(); texto.setEditable(false); c.add(new JScrollPane(texto));; frame.setSize(400,400); frame.show(); } public void print(String linha) { texto.append(linha); } public void println(String linha) { print(linha+'\n'); } }