Package javax.swing.text

Examples of javax.swing.text.EditorKit


   * Create the TextArea
   */
  public BeanShellEditor() {
    setDocument(new SyntaxDocument());

    EditorKit editorKit = new StyledEditorKit() {
      public Document createDefaultDocument() {
        return new SyntaxDocument();
      }
    };

View Full Code Here


    /**
     * Given some html, extracts its text.
     */
    public static String extractTextFromHTML(final String html) {
        try {
            final EditorKit kit = new HTMLEditorKit();
            final Document doc = kit.createDefaultDocument();

            // The Document class does not yet handle charset's properly.
            doc.putProperty("IgnoreCharsetDirective", Boolean.TRUE);

            // Create a reader on the HTML content.
            final Reader rd = new StringReader(html);

            // Parse the HTML.
            kit.read(rd, doc, 0);

            // The HTML text is now stored in the document
            return doc.getText(0, doc.getLength());
        } catch (final Exception e) {
        }
View Full Code Here

        assertNull(basicTextUI.create(elem));
        assertNull(basicTextUI.create(elem, 0, 5));
    }

    public void testGetEditorKit() {
        EditorKit editorKit = basicTextUI.getEditorKit(jta);
        assertTrue(editorKit instanceof DefaultEditorKit);
        assertFalse(editorKit instanceof StyledEditorKit);
        //JEditorPane is not support yet
        //assertEquals(editorKit, basicTextUI.getEditorKit(new JTextPane()));
        //assertEquals(editorKit, basicTextUI.getEditorKit(new JEditorPane()));
View Full Code Here

        testList.remove(listener1);
        assertEquals(testList, listeners);
    }

    public void testCreateDefaultEditorKit() {
        EditorKit kit1 = jep.createDefaultEditorKit();
        EditorKit kit2 = jep.createDefaultEditorKit();
        assertEquals("javax.swing.JEditorPane$PlainEditorKit", kit1.getClass().getName());
        assertNotSame(kit1, kit2);
    }
View Full Code Here

            throw new UnsupportedOperationException("Not implemented");
        }
        SimplePropertyChangeListener listener = new SimplePropertyChangeListener();
        jep.addPropertyChangeListener("editorKit", listener);
        PropertyChangeEvent event;
        EditorKit kit0 = jep.getEditorKit();
        SimpleEditorKit kit1 = new SimpleEditorKit();
        SimpleEditorKit kit2 = new SimpleEditorKit();
        assertEquals("javax.swing.JEditorPane$PlainEditorKit", kit0.getClass().getName());
        event = new PropertyChangeEvent(jep, "editorKit", kit0, kit1);
        jep.setEditorKit(kit1);
        assertEquals(kit1, jep.getEditorKit());
        assertEquals(event, listener.event);
        assertTrue(kit1.wasCallInstall);
        assertFalse(kit1.wasCallDeinstall);
        listener.resetDbgInfo();
        kit1.resetDbgInfo();
        event = new PropertyChangeEvent(jep, "editorKit", kit1, kit2);
        jep.setEditorKit(kit2);
        assertEquals(kit2, jep.getEditorKit());
        assertEquals(event, listener.event);
        assertTrue(kit2.wasCallInstall);
        assertFalse(kit2.wasCallDeinstall);
        assertFalse(kit1.wasCallInstall);
        assertTrue(kit1.wasCallDeinstall);
        kit2.resetDbgInfo();
        jep.setEditorKit(null);
        kit0 = jep.getEditorKit();
        event = new PropertyChangeEvent(jep, "editorKit", kit2, kit0);
        assertEquals("javax.swing.JEditorPane$PlainEditorKit", kit0.getClass().getName());
        assertTrue(kit2.wasCallDeinstall);
        //temporarily commented-out: HTMLEditorKit,
        //DefaultStyledDocument not implemented
        /*assertEquals("text/plain", jep.getContentType());
         jep.setEditorKit(new HTMLEditorKit());
View Full Code Here

        assertEquals("JEditorPane.honorDisplayProperties", JEditorPane.HONOR_DISPLAY_PROPERTIES);
        assertEquals("JEditorPane.w3cLengthUnits", JEditorPane.W3C_LENGTH_UNITS);
    }

    public void testPlainEditorKit() {
        EditorKit kit = jep.getEditorKit();
        assertEquals(kit, kit.getViewFactory());
    }
View Full Code Here

        thread1.go();
        ThreadCheckEditorKit thread2 = new ThreadCheckEditorKit(false);
        thread2.go();

        Map<EditorKit, Object> kitMap = new HashMap<EditorKit, Object>();
        EditorKit result;

        for (int i = 0; i < 9; i++) {
            result = thread1.result[i];

            if (i < 3) {
                assertNull(result);
            } else {
                assertNotNull(result);
                kitMap.put(result, null);
                assertEquals(result.getClass().getClassLoader(),
                        ((i % 3) == 2) ? classLoader2 : classLoader1);
            }
            result = thread2.result[i];
            assertNotNull(result);
            kitMap.put(result, null);
            assertEquals(result.getClass().getClassLoader(),
                    (((i % 3) == 2) ? classLoader2 : classLoader1));
        }
        // Make sure all returned values are unique.
        assertEquals(kitMap.size(), 15);
    }
View Full Code Here

        assertSame(textPane.getEditorKit(), textPane.getStyledEditorKit());
        assertSame(textPane.getStyledEditorKit(), textPane.getStyledEditorKit());
    }

    public void testCreateDefaultEditorKit() {
        EditorKit editorKit1 = textPane.createDefaultEditorKit();
        EditorKit editorKit2 = textPane.createDefaultEditorKit();
        assertNotSame(editorKit1, editorKit2);
        assertEquals("javax.swing.text.StyledEditorKit", editorKit1.getClass().getName());
    }
View Full Code Here

        assertNull(basicTextUI.create(elem));
        assertNull(basicTextUI.create(elem, 0, 5));
    }

    public void testGetEditorKit() {
        EditorKit editorKit = basicTextUI.getEditorKit(jta);
        assertTrue(editorKit instanceof DefaultEditorKit);
        assertFalse(editorKit instanceof StyledEditorKit);
        //JEditorPane is not support yet
        //assertEquals(editorKit, basicTextUI.getEditorKit(new JTextPane()));
        //assertEquals(editorKit, basicTextUI.getEditorKit(new JEditorPane()));
View Full Code Here

        }
        return editorKit;
    }

    public EditorKit getEditorKitForContentType(final String type) {
        EditorKit kit = localContentTypes.get(type);

        if (kit == null) {
            kit = createEditorKitForContentType(type);

            if (kit == null) {
View Full Code Here

TOP

Related Classes of javax.swing.text.EditorKit

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.