Package javax.swing.text

Examples of javax.swing.text.PlainDocument


   *
   * @return a dummy element for testing
   */
  static Element createDummyElement()
  {
    PlainDocument doc = new PlainDocument();
    return doc.getDefaultRootElement();
  }
View Full Code Here


  }
 
  public void test1(TestHarness harness)
  {
    harness.checkPoint("test1");
    PlainDocument d = new PlainDocument();
    try
    {
      Position p0 = d.createPosition(0);
      harness.check(p0.getOffset(), 0);
      Position p1 = d.createPosition(1);
      harness.check(p1.getOffset(), 1);
      d.insertString(0, "ABC", null);
      harness.check(p0.getOffset(), 0);
      harness.check(p1.getOffset(), 4);
    }
    catch (BadLocationException e)
    {
View Full Code Here

  }

  public void test2(TestHarness harness)
  {
    harness.checkPoint("test2");
    PlainDocument d = new PlainDocument();
    try
    {
      d.insertString(0, "ABC", null);
      Position p0 = d.createPosition(0);
      harness.check(p0.getOffset(), 0);
      Position p1 = d.createPosition(1);
      harness.check(p1.getOffset(), 1);
      Position p2 = d.createPosition(3);
      harness.check(p2.getOffset(), 3);
      Position p3 = d.createPosition(4);
      harness.check(p3.getOffset(), 4);
     
      d.insertString(1, "XYZ", null);
      harness.check(p0.getOffset(), 0);
      harness.check(p1.getOffset(), 4);
      harness.check(p2.getOffset(), 6);
      harness.check(p3.getOffset(), 7);
     
      d.remove(2, 3);
      harness.check(p0.getOffset(), 0);
      harness.check(p1.getOffset(), 2);
      harness.check(p2.getOffset(), 3);
      harness.check(p3.getOffset(), 4);     
    }
View Full Code Here

     * document.
     *
     * @return the default backing document
     */
    protected Document createDefaultDocument() {
        return new PlainDocument();
    }
View Full Code Here

        }

        public static Component createInputPasswordComponent(final Object model,
                                                 final AttributeSet attrs,
                                                 final FormView view) {
            PlainDocument document = (PlainDocument) model;
            final JPasswordField passwordField = new JPasswordField();

            // Model
            if (document == null) {
                document = new FormTextModel(new Form(SimpleAttributeSet.EMPTY),
View Full Code Here

        }

        public static Component createInputTextComponent(final Object model,
                                                     final AttributeSet attrs,
                                                     final FormView view) {
            PlainDocument document = (PlainDocument) model;
            final JTextField textField = new JTextField();

            // Model
            if (document == null) {
                document = new FormTextModel(new Form(SimpleAttributeSet.EMPTY),
View Full Code Here

        public static Component createInputFileComponent(final Object model,
                                                     final AttributeSet attrs) {
            /*
             * FilePath attributes
             */
            PlainDocument document = (PlainDocument) model;
            final JTextField filePath = new JTextField();

            // Model
            if (document == null) {
                document = new FormTextModel(new Form(SimpleAttributeSet.EMPTY),
View Full Code Here

                                                        final FormView view) {
            /*
             * JTextArea attributes
             */
            Dimension size;
            PlainDocument document = (PlainDocument)model;

            //ROWS
            int rowsCount = DEFAULT_ROWS_COUNT;
            String attribute = (String)attrs.getAttribute(HTML.Attribute.ROWS);
            if (!Utilities.isEmptyString(attribute)) {
View Full Code Here

    TextComponent() {
        state = new State();
        editable = true;
        dispatchToIM = true; // had been disabled by createBehavior()
        setFont(new Font("DialogInput", Font.PLAIN, 12)); // QUICK FIX
        document = new PlainDocument();
        //        text = new StringBuffer();
        setTextKit(new TextKitImpl());
        rootViewContext = createRootViewContext();
        rootViewContext.getView().append(createView());
        rootViewContext.getView().setSize(w, h);
View Full Code Here

        int max = Math.max(prefWidth, value);
        return new DefaultBoundedRangeModel(value, max - value, 0, max);
    }

    protected Document createDefaultModel() {
        return new PlainDocument();
    }
View Full Code Here

TOP

Related Classes of javax.swing.text.PlainDocument

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.