Package javax.swing.text

Examples of javax.swing.text.Highlighter


       
        // We can't simply remove all highlighters, since if the user has text selected,
        // there will be a highlighter to indicate the text selection. This fixes a bug
        // where selected text becomes invisible after the syntax smarts run, because
        // the selection highlight was removed here.
        Highlighter highlighter = getEditor().getHighlighter();
        Highlight[] highlights = highlighter.getHighlights();
       
        for (final Highlight highlight : highlights) {
            if (highlight.getPainter() instanceof ErrorUnderlineHighlightPainter) {
                highlighter.removeHighlight(highlight);
            }
        }

        errorOffsets.clear();
        sidePanel.repaint();
View Full Code Here


        }
       
        ambiguityOffsets.add(offset);
       
        try {
            Highlighter highlighter = getHighlighter();
            highlighter.addHighlight(offset.getStartOffset(), offset.getEndOffset(), new AmbiguityUnderlineHighlightPainter());
           
        } catch (BadLocationException ex) {
            throw new IllegalStateException("bad location adding highlight");
        }
    }
View Full Code Here

    /**
     * Clears all ambiguity indicators.
     */
    private void clearAmbiguityIndicators() {
       
        Highlighter highlighter = getHighlighter();
        Highlight[] highlights = highlighter.getHighlights();
       
        for (final Highlight highlight : highlights) {
            if (highlight.getPainter() instanceof AmbiguityUnderlineHighlightPainter) {
                highlighter.removeHighlight(highlight);
            }
        }

        ambiguityOffsets.clear();
    }   
View Full Code Here

        });

    }

    public void setHighlightText(int lastIndex, int endIndex) throws BadLocationException {
        Highlighter highlighter = pane.getHighlighter();
        removeHighlightText(highlighter);
        highlighter.addHighlight(lastIndex, endIndex, painter);
    }
View Full Code Here

     * @param int size
     * @param String message - text for toolTip, contains the text of the error
     */

    public void setHighlightText(int line, int lastIndex, int size, String message) {
        Highlighter highlighter = pane.getHighlighter();
        removeHighlightText(highlighter);
        if (getText().length() > 0) {
            try {
                int position = getPosition(line, lastIndex);
                int positionEnd = position + size;
                highlighter.addHighlight(position, positionEnd, painter);
                setToolTipPosition(line, message);
                repaintPane();
            }
            catch (BadLocationException e) {
                logObj.warn("Error: ", e);
View Full Code Here

        }
    }

    public void removeHighlightText() {
        imageError = false;
        Highlighter highlighter = pane.getHighlighter();
        removeHighlightText(highlighter);
    }
View Full Code Here

            return linkPos != -1 ? doc.getCharacterElement(linkPos) : null;
        }

        private static void moveHighlight(final JEditorPane editor,
                                          final int start, final int end) {
            Highlighter highlighter = editor.getHighlighter();
            Object tag = highlightTags.get(highlighter);
            if (tag != null) {
                highlighter.removeHighlight(tag);
                highlightTags.remove(highlighter);
            }
            try {
                tag = highlighter.addHighlight(start, end,
                                               new LinkHighlightPainter());
                highlightTags.put(highlighter, tag);
                editor.getCaret().setDot(start);
            } catch (final BadLocationException e) {
            }
View Full Code Here

            } catch (final BadLocationException e) {
            }
        }

        static void removeHighlight(final JEditorPane editor) {
            Highlighter highlighter = editor.getHighlighter();
            Object tag = highlightTags.get(highlighter);
            if (tag != null) {
                highlighter.removeHighlight(tag);
                highlightTags.remove(highlighter);
            }
        }
View Full Code Here

       
        final Document doc = document;
       
        readLock(doc);
        try {
            Highlighter highlighter = component.getHighlighter();
            Caret caret = component.getCaret();
            if (component.isOpaque()) {
                paintBackground(g);
            }
            if (highlighter != null) {
                highlighter.paint(g);
            }
            Rectangle visibleRect = getVisibleEditorRect();
            if (visibleRect != null) {
                getRootView().setSize(visibleRect.width, visibleRect.height);
                getRootView().paint(g, visibleRect);
View Full Code Here

       
       
       
        // TODO change layered highlight painting code
        JTextComponent tc = (JTextComponent)getContainer();
        Highlighter hl = tc.getHighlighter();
        if (hl instanceof LayeredHighlighter) {
            ((LayeredHighlighter)hl).paintLayeredHighlights(g,
                                                            getStartOffset(),
                                                            getEndOffset(),
                                                            shape, tc, this);
View Full Code Here

TOP

Related Classes of javax.swing.text.Highlighter

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.