Package javax.swing.text

Examples of javax.swing.text.PlainDocument


        }
        return count;
    }

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


        Object selected = comboBox.getSelectedItem();
        comboBox.getEditor().setItem(selected);
    }

    private void fillItem2StringMap() {
        editor.setDocument(new PlainDocument());

        item2string.clear();

        JTextComponent editor = (JTextComponent)comboBox.getEditor().getEditorComponent();
View Full Code Here

      label = label.substring( 0, limit );

    setText( label );


    setDocument( new PlainDocument()
          {
            public void insertString( int offset, String str, AttributeSet attribSet )
            {
              if( str == null )
                return;
View Full Code Here

            new Thread() {
                public void run() {
                    char [] buffer = new char[4096];

                    try {
                        Document  doc = new PlainDocument();

                        ParsedURL purl = new ParsedURL(svgDocument.getURL());
                        InputStream is
                            = u.openStream(getInputHandler(purl).
                                           getHandledMimeTypes());
                        // u.openStream(MimeTypeConstants.MIME_TYPES_SVG);

                        Reader in = XMLUtilities.createXMLDocumentReader(is);
                        int len;
                        while ((len=in.read(buffer, 0, buffer.length)) != -1) {
                            doc.insertString(doc.getLength(),
                                             new String(buffer, 0, len), null);
                        }

                        ta.setDocument(doc);
                        ta.setEditable(false);
View Full Code Here

    descPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 7, 0));

    JPanel typePanel = new JPanel(new BorderLayout());

    namePanel.add(new JLabel(mLocalizer.msg("componentName", "Component name:")), BorderLayout.WEST);
    mNameTF = new JTextField(new PlainDocument() {

      public void insertString(int offset, String str, AttributeSet a) throws BadLocationException {
        str = str.replaceAll(REGEX_INVALID_CHARACTERS, "_");
        super.insertString(offset, str, a);
      }
View Full Code Here

    }

    JPanel northPanel = new JPanel();
    northPanel.setLayout(new BoxLayout(northPanel, BoxLayout.Y_AXIS));

    mFilterNameTF = new JTextField(new PlainDocument() {

      public void insertString(int offset, String str, AttributeSet a) throws BadLocationException {
        str = str.replaceAll("[\\p{Punct}&&[^_]]", "_");
        super.insertString(offset, str, a);
      }
View Full Code Here

    }

    public void testJTextFieldDocumentStringInt() {
        String str1 = "AAA";
        String str2 = "testJTextFieldDocumentStringInt()";
        Document doc = new PlainDocument();
        try {
            doc.insertString(0, str2, null);
        } catch (BadLocationException e) {
            assertTrue("Unexpected exception: " + e.getMessage(), false);
        }
        JTextField tf = new JTextField(doc, str2, 8);
        assertEquals(str2, tf.getText());
        assertEquals(doc, tf.getDocument());
        assertEquals(8, tf.getColumns());
        doc = new PlainDocument();
        try {
            doc.insertString(0, str2, null);
        } catch (BadLocationException e) {
            assertTrue("Unexpected exception: " + e.getMessage(), false);
        }
        tf = new JTextField(doc, null, 6);
        assertEquals(str2, tf.getText());
View Full Code Here

        assertEquals("", ae.getActionCommand());
    }

    public void testSetDocument() {
        Document old = jtf.getDocument();
        Document doc = new PlainDocument();
        jtf.setDocument(doc);
        testPropertyChangeEvent("document", old, doc, listener.event);
        assertEquals(Boolean.TRUE, doc.getProperty("filterNewlines"));
    }
View Full Code Here

        jta.setLineWrap(true);
        assertTrue(jta.getScrollableTracksViewportWidth());
    }

    public void testJTextAreaDocumentStringintint() {
        Document doc = new PlainDocument();
        try {
            doc.insertString(0, str2, null);
            ExtJTextArea ta = new ExtJTextArea(doc, str1, 3, 8);
            assertEquals(str1, ta.getText());
            assertEquals(doc, ta.getDocument());
            assertEquals(3, ta.getRows());
            assertEquals(8, ta.getColumns());
            assertFalse(ta.getLineWrap());
            assertFalse(ta.getWrapStyleWord());
            doc = new PlainDocument();
            doc.insertString(0, str2, null);
            ta = new ExtJTextArea(doc, null, 5, 6);
            assertEquals(str2, ta.getText());
            ta = new ExtJTextArea(doc, "", 5, 6);
            assertEquals("", ta.getText());
            try {
View Full Code Here

            assertTrue("Unexpected exception: " + e.getMessage(), false);
        }
    }

    public void testJTextAreaDocument() {
        Document doc = new PlainDocument();
        try {
            doc.insertString(0, str2, null);
        } catch (BadLocationException e) {
            assertTrue("Unexpected exception: " + e.getMessage(), false);
        }
        ExtJTextArea ta = new ExtJTextArea(doc);
        assertEquals(str2, ta.getText());
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.