All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jp.kyasu.awt.util.LimitTextEditModel

java.lang.Object
   |
   +----jp.kyasu.awt.DefaultTextModel
           |
           +----jp.kyasu.awt.DefaultTextEditModel
                   |
                   +----jp.kyasu.awt.util.LimitTextEditModel

public class LimitTextEditModel
extends DefaultTextEditModel
The LimitTextEditModel class implements the TextEditModel interface. The LimitTextEditModel object limits the length of the text.

An example of using the LimitTextEditModel is:

     final Dialog dialog = new Dialog(new Frame(), "LimitTextEditModel", true);
     dialog.setLayout(new FlowLayout());
     dialog.addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
             dialog.setVisible(false);
             System.exit(0);
         }
     });
     Label label = new Label("Input message (<= 10):");
     dialog.add(label);
     RichText rtext = new RichText(TextField.DEFAULT_FIELD_STYLE);
     TextField field = new TextField(new LimitTextEditModel(rtext, 10), 10);
     dialog.add(field);
     dialog.pack();
     dialog.setVisible(true);
 

Version:
15 Dec 1997
Author:
Kazuki YASUMATSU
See Also:
TextEditModel

Constructor Index

 o LimitTextEditModel(RichText, int)
Constructs a model with the specified rich text and limit length of the text.

Method Index

 o replace(int, int, Text)
Replaces the specified range of the rich text of this model with the specified replacement text object.
 o setRichText(RichText)
Sets the rich text of this model to be the specified rich text.

Constructors

 o LimitTextEditModel
 public LimitTextEditModel(RichText richText,
                           int limitSize)
Constructs a model with the specified rich text and limit length of the text.

Parameters:
richText - the rich text.
limitSize - the limit length of the text.

Methods

 o setRichText
 public synchronized void setRichText(RichText richText)
Sets the rich text of this model to be the specified rich text.

Parameters:
richText - the rich text.
Overrides:
setRichText in class DefaultTextEditModel
 o replace
 public synchronized Undo replace(int begin,
                                  int end,
                                  Text rep)
Replaces the specified range of the rich text of this model with the specified replacement text object.

Parameters:
begin - the beginning text position to replace, inclusive.
end - the ending text position to replace, exclusive.
rep - a replacement Text object.
Returns:
the undo object for this operation, or null if the undo is not supported.
Overrides:
replace in class DefaultTextEditModel

All Packages  Class Hierarchy  This Package  Previous  Next  Index