Package javax.swing.text

Examples of javax.swing.text.Caret


        if (!(c instanceof JTextComponent)) {
            throw new IllegalArgumentException(Messages.getString("swing.77")); //$NON-NLS-1$
        }
        Dimension dim = super.getPreferredSize(c);

        Caret caret = ((JTextComponent)c).getCaret();
        if (caret != null && caret instanceof DefaultCaret) {
            dim.width += ((DefaultCaret)caret).width;
        }
        return dim;
    }
View Full Code Here


     */
    public void showCodeEditorPopupMenu() throws AutoCompletePopupMenu.AutoCompleteException {
       
        try {
            JTextComponent editorPane = editor.getEditorComponent();
            Caret caret = editorPane.getCaret();
            final int caretPos = Math.min(caret.getMark(), caret.getDot());           
            Point location = editorPane.getUI().modelToView(editorPane, caretPos).getLocation();
            int height = editorPane.getFontMetrics(editorPane.getFont()).getHeight();
            location = new Point (location.x, location.y + height);
            try {
                autoCompletePopup.start(perspective, editor.getEditorComponent(), location);       
View Full Code Here

            // Obtain the offset where to jump
            pos = Utilities.getRowStartFromLineOffset(doc, line);
        }

        if (pos != -1) {
            Caret caret = pane.getCaret();
            if (caret instanceof BaseCaret) { // support extended scroll mode
                BaseCaret bCaret = (BaseCaret)caret;
                bCaret.setDot(pos, bCaret, EditorUI.SCROLL_FIND);
            }
            else {
                caret.setDot(pos);
            }
        }
    }
View Full Code Here

            if (getEditor(e).isEditable()) {
                return;
            }

            JEditorPane editor = getEditor(e);
            Caret caret = editor.getCaret();
            HTMLDocument doc = getHTMLDocument(editor);

            Element link = getNextLinkElement(doc, caret.getDot(), isForward());
            if (link != null) {
                moveHighlight(editor,
                              link.getStartOffset(), link.getEndOffset());
            }
        }
View Full Code Here

        installDefaults();
        LookAndFeel.installProperty(component, StringConstants.OPAQUE_PROPERTY,
                                    Boolean.TRUE);

        if (Utilities.isUIResource(component.getCaret())) {
            Caret caret = createCaret();
            component.setCaret(caret);
            caret.setBlinkRate(UIManager.getInt(getPropertyPrefix()
                                                  + ".caretBlinkRate"));
        }

        if (Utilities.isUIResource(component.getHighlighter())) {
            component.setHighlighter(createHighlighter());
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);
            }
            caret.paint(g);
        } finally {
            readUnlock(doc);
        }
    }
View Full Code Here

            if (getEditor(e).isEditable()) {
                return;
            }

            JEditorPane editor = getEditor(e);
            Caret caret = editor.getCaret();
            HTMLDocument doc = getHTMLDocument(editor);

            Element link = getNextLinkElement(doc, caret.getDot(), isForward());
            if (link != null) {
                moveHighlight(editor,
                              link.getStartOffset(), link.getEndOffset());
            }
        }
View Full Code Here

        installDefaults();
        LookAndFeel.installProperty(component, StringConstants.OPAQUE_PROPERTY,
                                    Boolean.TRUE);

        if (Utilities.isUIResource(component.getCaret())) {
            Caret caret = createCaret();
            component.setCaret(caret);
            caret.setBlinkRate(UIManager.getInt(getPropertyPrefix()
                                                  + ".caretBlinkRate"));
        }

        if (Utilities.isUIResource(component.getHighlighter())) {
            component.setHighlighter(createHighlighter());
View Full Code Here

            return;
        }
        readLock();
        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);
            }
            caret.paint(g);
        } finally {
            readUnlock();
        }
    }
View Full Code Here

        Highlighter highlighter = basicTextUI.createHighlighter();
        assertTrue(highlighter instanceof BasicTextUI.BasicHighlighter);
    }

    public void testCreateCaret() {
        Caret caret = basicTextUI.createCaret();
        assertTrue(caret instanceof BasicTextUI.BasicCaret);
    }
View Full Code Here

TOP

Related Classes of javax.swing.text.Caret

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.