Package javax.swing.text

Examples of javax.swing.text.Highlighter$HighlightPainter


        responsePanel.setTabFocus();
        responsePanel.requestFocus();
        break;
      }
       
        Highlighter hilite = txtArea.getHighlighter();
        HighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(Color.LIGHT_GRAY);
        try {
      hilite.removeAllHighlights();
      hilite.addHighlight(sm.getStart(), sm.getEnd(), painter);
      txtArea.setCaretPosition(sm.getStart());
    } catch (BadLocationException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
View Full Code Here


   * @see #markAll
   * @see #getMarkAllHighlightColor
   * @see #setMarkAllHighlightColor
   */
  public void clearMarkAllHighlights() {
    Highlighter h = getHighlighter();
    if (h!=null && markAllHighlights!=null) {
      int count = markAllHighlights.size();
      for (int i=0; i<count; i++)
        h.removeHighlight(markAllHighlights.get(i));
      markAllHighlights.clear();
    }
    markedWord = null;
    repaint();
  }
View Full Code Here

   * @see #getMarkAllHighlightColor
   * @see #setMarkAllHighlightColor
   */
  public int markAll(String toMark, boolean matchCase, boolean wholeWord,
          boolean regex) {
    Highlighter h = getHighlighter();
    int numMarked = 0;
    if (toMark!=null && !toMark.equals(markedWord) && h!=null) {
      if (markAllHighlights!=null)
        clearMarkAllHighlights();
      else
        markAllHighlights = new ArrayList(10);
      int caretPos = getCaretPosition();
      markedWord = toMark;
      setCaretPosition(0);
      boolean found = SearchEngine.find(this, toMark, true, matchCase,
                    wholeWord, regex);
      while (found) {
        int start = getSelectionStart();
        int end = getSelectionEnd();
        try {
          markAllHighlights.add(h.addHighlight(start, end,
                    markAllHighlightPainter));
        } catch (BadLocationException ble) {
          ble.printStackTrace();
        }
        numMarked++;
View Full Code Here

    public void clearAllSnippetHighlights() {
        if (currentCodeFilesInfo != null) {
            snippetMap.setCurrentSet(null);
            for(CodeFileInfo code : currentCodeFilesInfo.values()) {
                if (code != null && code.textPane != null) {
                    Highlighter highlighter = code.textPane.getHighlighter();
                    highlighter.removeAllHighlights();
                    code.textPane.repaint();
                    code.veneer.repaint();
                }
            }
        }
View Full Code Here

        URL files[] = snippetMap.getFilesForSet(snippetKey);
        CodeFileInfo firstCodeFileInfo = null;
        Snippet firstSnippet = null;
        for(URL file : files) {
            CodeFileInfo codeFileInfo = codeCache.get(file);
            Highlighter highlighter = codeFileInfo.textPane.getHighlighter();
            // now add highlight for each snippet in this file associated
            // with the key
            Snippet snippets[] = snippetMap.getSnippetsForFile(snippetKey, file);
            if (firstCodeFileInfo == null) {
                firstCodeFileInfo = codeFileInfo;
                firstSnippet = snippets[0];
            }
            for (Snippet snippet : snippets) {
                try {
                    highlighter.addHighlight(snippet.startLine,
                            snippet.endLine, snippetPainter );
                    codeFileInfo.veneer.repaint();
                } catch (BadLocationException e) {
                    e.printStackTrace();
                }
View Full Code Here

        if (!isActive) {
            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);
View Full Code Here

    public void testGetComponent() {
        assertEquals(jta, ((BasicTextUI) jta.getUI()).getComponent());
    }

    public void testCreateHighlighter() {
        Highlighter highlighter = basicTextUI.createHighlighter();
        assertTrue(highlighter instanceof BasicTextUI.BasicHighlighter);
    }
View Full Code Here

        new javax.swing.JTextPane().updateUI();           
    }

    public void testInstallUI() throws Exception {
        Caret caret = jta.getCaret();
        Highlighter highlighter = jta.getHighlighter();
        String prefix = ((BasicTextUI) tf.getUI()).getPropertyPrefix();
        (jta.getUI()).uninstallUI(jta);
        TextUI ui = jta.getUI();
        assertTrue(ui instanceof TextAreaUI);
        TextAreaUI.callOrder = "";
View Full Code Here

        assertTrue(caret instanceof DefaultCaret);
        assertTrue(caret instanceof UIResource);
    }

    public void testBasicHighlighter() {
        Highlighter highlighter = new BasicTextUI.BasicHighlighter();
        assertTrue(highlighter instanceof DefaultHighlighter);
        assertTrue(highlighter instanceof UIResource);
    }
View Full Code Here

      JList list = (JList)c;
      Object[] values = list.getSelectedValues();
      StringBuilder sb = new StringBuilder();
      for (int i = 0; i < values.length; i++) {
        TreeFromFile val = (TreeFromFile) values[i];
        Highlighter h = val.getLabel().getHighlighter();
        Highlight[] highlights = h.getHighlights();
        if(highlights == null || highlights.length == 0) {
          sb.append(val.getLabel().getText());
        } else {
          //we have a highlight
          for(int j = 0; i < highlights.length; i++) {
View Full Code Here

TOP

Related Classes of javax.swing.text.Highlighter$HighlightPainter

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.