javax.swing.text.EditorKit Java Examples

The following examples show how to use javax.swing.text.EditorKit. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CloneableEditorDoubleLoadingTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
protected void loadFromStreamToKit(StyledDocument doc, InputStream stream, EditorKit kit)
throws IOException, BadLocationException {
    Exception e = new Exception();
    StringWriter sw = new StringWriter(500);
    PrintWriter pw = new PrintWriter(sw);
    pw.println("loadFromStreamToKit"
    + " this:[" + Integer.toHexString(System.identityHashCode(doc)) + "]"
    + " thread:" + Thread.currentThread().getName());
    e.printStackTrace(pw);
    pw.flush();

    inits.add(new Exception(sw.toString()));
    
    super.loadFromStreamToKit(doc, stream, kit);
}
 
Example #2
Source File: ViewEditorView.java    From MogwaiERDesignerNG with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Initialize method.
 */
private void initialize() {

    EditorKit editorKit = new SQLEditorKit();
    sqlText.setEditorKitForContentType("text/sql", editorKit);
    sqlText.setContentType("text/sql");

    String rowDef = "2dlu,p,2dlu,p,fill:220dlu,10dlu,p,2dlu";
    String colDef = "2dlu,left:45dlu,2dlu,fill:140dlu:grow,fill:60dlu,2dlu,fill:60dlu,2dlu";

    FormLayout layout = new FormLayout(colDef, rowDef);
    setLayout(layout);

    CellConstraints cons = new CellConstraints();

    add(getComponent1(), cons.xywh(2, 2, 1, 1));
    add(getEntityName(), cons.xywh(4, 2, 4, 1));
    add(getMainTabbedPane(), cons.xywh(2, 4, 6, 2));
    add(getOkButton(), cons.xywh(5, 7, 1, 1));
    add(getCancelButton(), cons.xywh(7, 7, 1, 1));
}
 
Example #3
Source File: DocumentationScrollPane.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Attempt to find the editor keystroke for the given editor action. */
private KeyStroke[] findEditorKeys(String editorActionName, KeyStroke defaultKey, JTextComponent component) {
    // This method is implemented due to the issue
    // #25715 - Attempt to search keymap for the keybinding that logically corresponds to the action
    KeyStroke[] ret = new KeyStroke[] { defaultKey };
    if (component != null) {
        TextUI componentUI = component.getUI();
        Keymap km = component.getKeymap();
        if (componentUI != null && km != null) {
            EditorKit kit = componentUI.getEditorKit(component);
            if (kit instanceof BaseKit) {
                Action a = ((BaseKit)kit).getActionByName(editorActionName);
                if (a != null) {
                    KeyStroke[] keys = km.getKeyStrokesForAction(a);
                    if (keys != null && keys.length > 0) {
                        ret = keys;
                    }
                }
            }
        }
    }
    return ret;
}
 
Example #4
Source File: EditorActionUtilities.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Get searchable editor kit for the given kit.
 * @param kit non-null kit.
 * @return non-null searchable kit.
 */
public static SearchableEditorKit getSearchableKit(EditorKit kit) {
    SearchableEditorKit searchableKit;
    if (kit instanceof SearchableEditorKit) {
        searchableKit = ((SearchableEditorKit)kit);
    } else {
        synchronized (kit2searchable) {
            searchableKit = kit2searchable.get(kit);
            if (searchableKit == null) {
                searchableKit = new DefaultSearchableKit(kit);
                registerSearchableKit(kit, searchableKit);
            }
        }
    }
    return searchableKit;
}
 
Example #5
Source File: BaseDocument.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Print into given container.
 *
 * @param container printing container into which the printing will be done.
 * @param usePrintColoringMap use printing coloring settings instead
 *  of the regular ones.
 * @param lineNumberEnabled if set to false the line numbers will not be printed.
 *  If set to true the visibility of line numbers depends on the settings
 *  for the line number visibility.
 * @param startOffset start offset of text to print
 * @param endOffset end offset of text to print
 */
public void print(PrintContainer container, boolean usePrintColoringMap, boolean lineNumberEnabled, int startOffset,
                  int endOffset) {
    readLock();
    try {
        EditorUI editorUI;
        EditorKit kit = getEditorKit();
        if (kit instanceof BaseKit) {
            editorUI = ((BaseKit) kit).createPrintEditorUI(this, usePrintColoringMap, lineNumberEnabled);
        } else {
            editorUI = new EditorUI(this, usePrintColoringMap, lineNumberEnabled);
        }

        DrawGraphics.PrintDG printDG = new DrawGraphics.PrintDG(container);
        DrawEngine.getDrawEngine().draw(printDG, editorUI, startOffset, endOffset, 0, 0, Integer.MAX_VALUE);
    } catch (BadLocationException e) {
        LOG.log(Level.WARNING, null, e);
    } finally {
        readUnlock();
    }
}
 
Example #6
Source File: LegacyFormattersProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private Formatter getFormatter() {
    if (legacyFormatter == null) {
        EditorKit kit = MimeLookup.getLookup(mimePath).lookup(EditorKit.class);
        if (kit != null) {
            try {
                Method createFormatterMethod = kit.getClass().getDeclaredMethod("createFormatter"); //NOI18N
                legacyFormatter = createFormatterMethod.invoke(kit);
            } catch (Exception e) {
                legacyFormatter = e;
            }
        } else {
            legacyFormatter = NO_FORMATTER;
        }
    }
    return legacyFormatter instanceof Formatter ? (Formatter) legacyFormatter : null;
}
 
Example #7
Source File: BrowserPane.java    From SwingBox with GNU Lesser General Public License v3.0 6 votes vote down vote up
private Document createDocument(EditorKit kit, URL page)
{
    // we have pageProperties, because we can be in situation that
    // old page is being removed & new page is not yet created...
    // we need somewhere store important data.
    Document doc = kit.createDefaultDocument();
    if (pageProperties != null)
    {
        // transfer properties discovered in stream to the
        // document property collection.
        for (Enumeration<String> e = pageProperties.keys(); e
                .hasMoreElements();)
        {
            Object key = e.nextElement();
            doc.putProperty(key, pageProperties.get(key));
        }
    }
    if (doc.getProperty(Document.StreamDescriptionProperty) == null)
    {
        doc.putProperty(Document.StreamDescriptionProperty, page);
    }
    return doc;
}
 
Example #8
Source File: PageFlowTestUtility.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private FacesConfig initFacesConfig() throws IOException, InterruptedException {
        assertNotNull(getJsfDO());
        editorSupport = (JSFConfigEditorSupport) getJsfDO().createCookie(JSFConfigEditorSupport.class);
        assertNotNull(editorSupport);
        Lookup lookup = getJsfDO().getLookup();
        assertNotNull(lookup);
        Util.registerXMLKit();
        EditorKit kit = JSFConfigEditorSupport.getEditorKit("text/x-jsf+xml");
        assert (kit instanceof XMLKit);
        editorSupport.edit();

//        MultiViewHandler h = MultiViews.findMultiViewHandler(TopComponent.getRegistry().getActivated());
//        h.requestVisible(h.getPerspectives()[2]);

        ((MultiViewCloneableTopComponent) TopComponent.getRegistry().getActivated()).getSubComponents()[1].activate();
        ((PageFlowView) TopComponent.getRegistry().getActivated()).getMultiview().getEditorPane();

        JSFConfigModel model = ConfigurationUtils.getConfigModel(getJsfDO().getPrimaryFile(), true);
        assertNotNull(model);
        FacesConfig myFacesConfig = model.getRootComponent();
        assertNotNull(myFacesConfig);
        return myFacesConfig;
    }
 
Example #9
Source File: ViewHierarchyRandomTesting.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static RandomTestContainer createContainer(EditorKit kit) throws Exception {
    // Ensure the new view hierarchy is turned on
    System.setProperty("org.netbeans.editor.linewrap", "true");
    // Set the property for synchronous highlights firing since otherwise
    // the repeatability of problems with view hierarchy is none or limited.
    System.setProperty("org.netbeans.editor.sync.highlights", "true");
    System.setProperty("org.netbeans.editor.linewrap.edt", "true");

    RandomTestContainer container = new RandomTestContainer();
    EditorPaneTesting.initContainer(container, kit);
    DocumentTesting.initContainer(container);
    DocumentTesting.initUndoManager(container);
    container.addCheck(new ViewHierarchyCheck());
    JEditorPane pane = EditorPaneTesting.getEditorPane(container);
    pane.putClientProperty("text-line-wrap", "words"); // SimpleValueNames.TEXT_LINE_WRAP
    return container;
}
 
Example #10
Source File: DocumentationScrollPane.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Attempt to find the editor keystroke for the given editor action. */
private KeyStroke[] findEditorKeys(String editorActionName, KeyStroke defaultKey, JTextComponent component) {
    // This method is implemented due to the issue
    // #25715 - Attempt to search keymap for the keybinding that logically corresponds to the action
    KeyStroke[] ret = new KeyStroke[] { defaultKey };
    if (component != null) {
        TextUI componentUI = component.getUI();
        Keymap km = component.getKeymap();
        if (componentUI != null && km != null) {
            EditorKit kit = componentUI.getEditorKit(component);
            if (kit instanceof BaseKit) {
                 Action a = ((BaseKit)kit).getActionByName(editorActionName);
                if (a != null) {
                    KeyStroke[] keys = km.getKeyStrokesForAction(a);
                    if (keys != null && keys.length > 0) {
                        ret = keys;
                    }
                }
            }
        }
    }
    return ret;
}
 
Example #11
Source File: BaseJspEditorSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
protected void saveFromKitToStream(StyledDocument doc, EditorKit kit, OutputStream stream) throws IOException, BadLocationException {
    Parameters.notNull("doc", doc);
    Parameters.notNull("kit", kit);

    String foundEncoding = (String) doc.getProperty(DOCUMENT_SAVE_ENCODING);
    String encoding = foundEncoding != null ? foundEncoding : defaulEncoding;
    Charset charset = Charset.forName("UTF-8"); //NOI18N
    try {
        charset = Charset.forName(encoding);
    } catch (IllegalCharsetNameException | UnsupportedCharsetException e) {
        LOGGER.log(Level.INFO, "Illegal charset found: {0}, defaulted to UTF-8 as warned by dialog", encoding);
    }
    writeByteOrderMark(charset, stream);
    super.saveFromKitToStream(doc, kit, stream);
}
 
Example #12
Source File: BIEditorSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
protected void saveFromKitToStream(StyledDocument doc, EditorKit kit, OutputStream stream)
        throws IOException, BadLocationException {
    
    if (guardedProvider != null) {
        Charset c = FileEncodingQuery.getEncoding(this.getDataObject().getPrimaryFile());
        Writer writer = guardedProvider.createGuardedWriter(stream, c);
        try {
            kit.write(writer, doc, 0, doc.getLength());
        } finally {
            writer.close();
        }
    } else {
        super.saveFromKitToStream(doc, kit, stream);
    }
}
 
Example #13
Source File: DocumentationScrollPane.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** Attempt to find the editor keystroke for the given editor action. */
private KeyStroke[] findEditorKeys(String editorActionName, KeyStroke defaultKey, JTextComponent component) {
    // This method is implemented due to the issue
    // #25715 - Attempt to search keymap for the keybinding that logically corresponds to the action
    KeyStroke[] ret = new KeyStroke[] { defaultKey };
    if (component != null) {
        TextUI componentUI = component.getUI();
        Keymap km = component.getKeymap();
        if (componentUI != null && km != null) {
            EditorKit kit = componentUI.getEditorKit(component);
            if (kit instanceof BaseKit) {
                Action a = ((BaseKit)kit).getActionByName(editorActionName);
                if (a != null) {
                    KeyStroke[] keys = km.getKeyStrokesForAction(a);
                    if (keys != null && keys.length > 0) {
                        ret = keys;
                    }
                }
            }
        }
    }
    return ret;
}
 
Example #14
Source File: BrowserPane.java    From SwingBox with GNU Lesser General Public License v3.0 6 votes vote down vote up
void read(InputStream in, Document doc) throws IOException
{
    EditorKit kit = getEditorKit();

    try
    {
        kit.read(in, doc, 0);

    } catch (ChangedCharSetException ccse)
    {
        // ignored, may be in the future will be processed
        throw ccse;
    } catch (BadLocationException ble)
    {
        throw new IOException(ble);
    }

}
 
Example #15
Source File: BaseJspEditorSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
protected StyledDocument createStyledDocument(EditorKit kit) {
    StyledDocument doc = super.createStyledDocument(kit);

    //#174763 workaround - there isn't any elegant place where to place
    //a code which needs to be run after document's COMPLETE initialization.
    //DataEditorSupport.createStyledDocument() creates the document via the
    //EditorKit.createDefaultDocument(), but some of the important properties
    //like Document.StreamDescriptionProperty or mimetype are set as the
    //document properties later.
    //A hacky solution is that a Runnable can be set to the postInitRunnable property
    //in the EditorKit.createDefaultDocument() and the runnable is run
    //once the document is completely initialized.
    Runnable postInitRunnable = (Runnable)doc.getProperty("postInitRunnable"); //NOI18N
    if(postInitRunnable != null) {
        postInitRunnable.run();
    }

    return doc;
}
 
Example #16
Source File: Typing.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public Typing(final EditorKit kit, final String textWithPipe) {
    try {
        SwingUtilities.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                pane = new JEditorPane();
                pane.setEditorKit(kit);
                Document doc = pane.getDocument();
                // Required by Java's default key typed
                doc.putProperty(Language.class, HTMLTokenId.language());
                doc.putProperty("mimeType", "text/html");
                int caretOffset = textWithPipe.indexOf('|');
                String text;
                if (caretOffset != -1) {
                    text = textWithPipe.substring(0, caretOffset) + textWithPipe.substring(caretOffset + 1);
                } else {
                    text = textWithPipe;
                }
                pane.setText(text);
                pane.setCaretPosition((caretOffset != -1) ? caretOffset : doc.getLength());
            }
        });
    } catch (InterruptedException | InvocationTargetException e) {
        throw new RuntimeException(e.getCause());
    }
}
 
Example #17
Source File: AdvancedActionPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public AdvancedActionPanel(AntProjectCookie project, Set/*<TargetLister.Target>*/ allTargets) {
    this.project = project;
    this.allTargets = allTargets;
    initComponents();
    Mnemonics.setLocalizedText(targetLabel, NbBundle.getMessage(AdvancedActionPanel.class, "AdvancedActionsPanel.targetLabel.text"));
    Mnemonics.setLocalizedText(targetDescriptionLabel, NbBundle.getMessage(AdvancedActionPanel.class, "AdvancedActionsPanel.targetDescriptionLabel.text"));
    Mnemonics.setLocalizedText(propertiesLabel, NbBundle.getMessage(AdvancedActionPanel.class, "AdvancedActionsPanel.propertiesLabel.text"));
    Mnemonics.setLocalizedText(verbosityLabel, NbBundle.getMessage(AdvancedActionPanel.class, "AdvancedActionsPanel.verbosityLabel.text"));
    // Hack; EditorKit does not permit "fallback" kits, so we have to
    // mimic what the IDE itself does:
    EditorKit kit = propertiesPane.getEditorKit();
    String clazz = kit.getClass().getName();
    if (clazz.equals("javax.swing.text.DefaultEditorKit") || // NOI18N
            clazz.equals("javax.swing.JEditorPane$PlainEditorKit")) { // NOI18N
        propertiesPane.setEditorKit(JEditorPane.createEditorKitForContentType("text/plain")); // NOI18N
    }
    // Make ENTER run OK, not change the combo box.
    targetComboBox.getInputMap().remove(KeyStroke.getKeyStroke("ENTER")); // NOI18N
    initializeFields();
}
 
Example #18
Source File: PresenterEditorAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void actionPerformed(ActionEvent evt) {
    // Find the right action for the corresponding editor kit
    JTextComponent component = getTextComponent(evt);
    if (component != null) {
        TextUI ui = component.getUI();
        if (ui != null) {
            EditorKit kit = ui.getEditorKit(component);
            if (kit != null) {
                Action action = EditorUtilities.getAction(kit, actionName);
                if (action != null) {
                    action.actionPerformed(evt);
                } else {
                    if (LOG.isLoggable(Level.FINE)) {
                        LOG.fine("Action '" + actionName + "' not found in editor kit " + kit + '\n'); // NOI18N
                    }
                }
            }
        }
    }
}
 
Example #19
Source File: TypingCompletionUnitTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public Context(final EditorKit kit, final String textWithPipe) {
    try {
        SwingUtilities.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                pane = new JEditorPane();
                pane.setEditorKit(kit);
                Document doc = pane.getDocument();
                // Required by Java's default key typed
                doc.putProperty(Language.class, JavaTokenId.language());
                doc.putProperty("mimeType", "text/x-java");
                int caretOffset = textWithPipe.indexOf('|');
                String text;
                if (caretOffset != -1) {
                    text = textWithPipe.substring(0, caretOffset) + textWithPipe.substring(caretOffset + 1);
                } else {
                    text = textWithPipe;
                }
                pane.setText(text);
                pane.setCaretPosition((caretOffset != -1) ? caretOffset : doc.getLength());
            }
        });
    } catch (Exception e) {
        throw new IllegalStateException(e);
    }
}
 
Example #20
Source File: BlockHighlighting.java    From netbeans with Apache License 2.0 5 votes vote down vote up
static String getMimeType(JTextComponent component) {
    Document doc = component.getDocument();
    String mimeType = (String) doc.getProperty("mimeType"); //NOI18N
    if (mimeType == null) {
        EditorKit kit = component.getUI().getEditorKit(component);
        if (kit != null) {
            mimeType = kit.getContentType();
        }
    }
    return mimeType;
}
 
Example #21
Source File: KeyBindingsUpdater.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void addKit(EditorKit kit) {
    Map<String,List<List<KeyStroke>>> actionName2BindingLocal;
    synchronized (this) {
        actionName2BindingLocal = actionName2Binding; // actionName2binding not mutated
        kitRefs.add(new KitReference(kit));
    }
    updateKits(actionName2BindingLocal, Collections.singletonList(new KitReference(kit)));
}
 
Example #22
Source File: DataEditorSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * @inheritDoc
 */
@Override
protected void saveFromKitToStream(StyledDocument doc, EditorKit kit, OutputStream stream) throws IOException, BadLocationException {
    if (doc == null) {
        throw new NullPointerException("Document is null"); // NOI18N
    }
    if (kit == null) {
        throw new NullPointerException("Kit is null"); // NOI18N
    }
    
    Charset c = charsets.get(this.getDataObject());
    if (c == null) {
        c = FileEncodingQuery.getEncoding(this.getDataObject().getPrimaryFile());
    }
    FilterOutputStream fos = new FilterOutputStream(stream) {
        @Override
        public void close() throws IOException {
            flush();
        }
    };
    Writer w = new OutputStreamWriter (fos, c);
    try {
        kit.write(w, doc, 0, doc.getLength());
    } finally {
        w.close();
    }
}
 
Example #23
Source File: EncodedReaderFactory.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public DocWriter(Document doc, FileObject fo, FileLock foLock, File file,
                 EditorKit kit, CloneableEditorSupport editorSupport,
                 Method saveFromKitToStreamMethod) {
    this.doc = doc;
    this.fo = fo;
    this.foLock = foLock;
    this.file = file;
    this.kit = kit;
    this.editorSupport = editorSupport;
    this.saveFromKitToStreamMethod = saveFromKitToStreamMethod;
}
 
Example #24
Source File: PropertiesEditorSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Reads the file from the stream, filter the guarded section
 * comments, and mark the sections in the editor. Overrides superclass method. 
 * @param document the document to read into
 * @param inputStream the open stream to read from
 * @param editorKit the associated editor kit
 * @throws <code>IOException</code> if there was a problem reading the file
 * @throws <code>BadLocationException</code> should not normally be thrown
 * @see #saveFromKitToStream
 */
@Override
protected void loadFromStreamToKit(StyledDocument document, InputStream inputStream, EditorKit editorKit) throws IOException, BadLocationException {
    final Charset c = getCharset();
    final Reader reader = new BufferedReader(new InputStreamReader(inputStream, c));

    try {
        editorKit.read(reader, document, 0);
    } finally {
        reader.close();
    }
}
 
Example #25
Source File: EditorSanityTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testApplicationRtfEditorKits() {
    JEditorPane pane = new JEditorPane();
    setContentTypeInAwt(pane, "application/rtf");
    
    // Test JDK kit
    EditorKit kitFromJdk = pane.getEditorKit();
    assertNotNull("Can't find JDK kit for application/rtf", kitFromJdk);
    assertTrue("Wrong JDK kit for application/rtf", kitFromJdk instanceof RTFEditorKit);
}
 
Example #26
Source File: MultiTextUI.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Invokes the <code>getEditorKit</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public EditorKit getEditorKit(JTextComponent a) {
    EditorKit returnValue =
        ((TextUI) (uis.elementAt(0))).getEditorKit(a);
    for (int i = 1; i < uis.size(); i++) {
        ((TextUI) (uis.elementAt(i))).getEditorKit(a);
    }
    return returnValue;
}
 
Example #27
Source File: InitializeInAWTTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static void assertKit(EditorKit kit) {
    if (kit instanceof NbLikeEditorKit) {
        NbLikeEditorKit nb = (NbLikeEditorKit) kit;
        assertNotNull("the kit's call mehtod expected to be called", nb.callThread);
    } else {
        fail("Should use NbLikeEditorKit: " + kit);
    }
}
 
Example #28
Source File: MultiTextUI.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the <code>getEditorKit</code> method on each UI handled by this object.
 *
 * @return the value obtained from the first UI, which is
 * the UI obtained from the default <code>LookAndFeel</code>
 */
public EditorKit getEditorKit(JTextComponent a) {
    EditorKit returnValue =
        ((TextUI) (uis.elementAt(0))).getEditorKit(a);
    for (int i = 1; i < uis.size(); i++) {
        ((TextUI) (uis.elementAt(i))).getEditorKit(a);
    }
    return returnValue;
}
 
Example #29
Source File: CloneableEditorCreationFinishedTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected EditorKit createEditorKit () {
    return new NbLikeEditorKit () {
        public Void call() throws Exception {
            while (true) {
                Thread.sleep(100);
                if (continueExecution()) {
                    break;
                }
            }
            super.call();
            return null;
        }

    };
}
 
Example #30
Source File: JBLabel.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void updateStyle(@Nonnull JEditorPane pane) {
  myEditorPane.setFont(getFont());
  myEditorPane.setForeground(getForeground());
  EditorKit kit = pane.getEditorKit();
  if (kit instanceof HTMLEditorKit) {
    StyleSheet css = ((HTMLEditorKit)kit).getStyleSheet();
    css.addRule("body, p {" +
                "color:#" + ColorUtil.toHex(getForeground()) + ";" +
                "font-family:" + getFont().getFamily() + ";" +
                "font-size:" + getFont().getSize() + "pt;" +
                "white-space:" + (myAllowAutoWrapping ? "normal" : "nowrap") + ";}");
  }
}