public final class TextAreaWriter extends Writer
Constructor and Description |
---|
TextAreaWriter(TextArea textArea) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
flush() |
static PrintWriter |
getTextPrintWriter(TextArea textArea)
Factory method for creating a PrintWriter to print to selected TextArea
|
void |
write(char[] cbuf,
int off,
int len) |
public TextAreaWriter(TextArea textArea)
textArea
- area where to write#import java.io.*; #import javax.swing.*; JTextArea text = new JTextArea(); PrintWriter tw = new PrintWriter(new TextAreaWriter(text)); tw.print("Hello"); tw.print(" "); tw.print("world!"); text.getText() === "Hello world!"; text.setText(""); tw.println("Hello"); tw.println("world!"); text.getText() =R= "Hello\\r?\\nworld!\\r?\\n";
public void flush()
public void close()
public void write(char[] cbuf, int off, int len) throws IOException
write
in class Writer
IOException
public static PrintWriter getTextPrintWriter(TextArea textArea)
textArea
- area where to print#import java.io.*; #import javax.swing.*; JTextArea text = new JTextArea(); PrintWriter tw = TextAreaWriter.getTextPrintWriter(text); tw.print("Hyvää"); tw.print(" "); tw.print("päivää!"); text.getText() === "Hyvää päivää!";