home *** CD-ROM | disk | FTP | other *** search
- package java.awt;
-
- import java.awt.peer.TextAreaPeer;
-
- public class TextArea extends TextComponent {
- int rows;
- int cols;
-
- public TextArea() {
- super("");
- }
-
- public TextArea(int rows, int cols) {
- super("");
- this.rows = rows;
- this.cols = cols;
- }
-
- public TextArea(String text) {
- super(text);
- }
-
- public TextArea(String text, int rows, int cols) {
- super(text);
- this.rows = rows;
- this.cols = cols;
- }
-
- public synchronized void addNotify() {
- super.peer = ((Component)this).getToolkit().createTextArea(this);
- super.addNotify();
- }
-
- public void insertText(String str, int pos) {
- TextAreaPeer peer = (TextAreaPeer)super.peer;
- if (peer != null) {
- peer.insertText(str, pos);
- } else {
- super.text = super.text.substring(0, pos) + str + super.text.substring(pos);
- }
- }
-
- public void appendText(String str) {
- if (super.peer != null) {
- this.insertText(str, ((TextComponent)this).getText().length());
- } else {
- super.text = super.text + str;
- }
- }
-
- public void replaceText(String str, int start, int end) {
- TextAreaPeer peer = (TextAreaPeer)super.peer;
- if (peer != null) {
- peer.replaceText(str, start, end);
- } else {
- super.text = super.text.substring(0, start) + str + super.text.substring(end);
- }
- }
-
- public int getRows() {
- return this.rows;
- }
-
- public int getColumns() {
- return this.cols;
- }
-
- public Dimension preferredSize(int rows, int cols) {
- TextAreaPeer peer = (TextAreaPeer)super.peer;
- return peer != null ? peer.preferredSize(rows, cols) : super.preferredSize();
- }
-
- public Dimension preferredSize() {
- return this.rows > 0 && this.cols > 0 ? this.preferredSize(this.rows, this.cols) : super.preferredSize();
- }
-
- public Dimension minimumSize(int rows, int cols) {
- TextAreaPeer peer = (TextAreaPeer)super.peer;
- return peer != null ? peer.minimumSize(rows, cols) : super.minimumSize();
- }
-
- public Dimension minimumSize() {
- return this.rows > 0 && this.cols > 0 ? this.minimumSize(this.rows, this.cols) : super.minimumSize();
- }
-
- protected String paramString() {
- return super.paramString() + ",rows=" + this.rows + ",cols=" + this.cols;
- }
- }
-