Package javax.swing.text

Examples of javax.swing.text.Highlighter.addHighlight()


              String fragment = document.getText(it.getStartOffset(), it
                  .getEndOffset()
                  - it.getStartOffset());
              Matcher matcher = pattern.matcher(fragment);
              while (matcher.find()) {
                highlighter.addHighlight(it.getStartOffset() + matcher.start(),
                    it.getStartOffset() + matcher.end(), painter);
              }
            } catch (BadLocationException ex) {
            }
          }
View Full Code Here


            int pos = 0;

            // Search for pattern
            while ((pos = text.indexOf(pattern, pos)) >= 0) {
                // Create highlighter using private painter and apply around pattern
                hilite.addHighlight(pos, pos+pattern.length(), myHighlightPainter);
                pos += pattern.length();
            }
        } catch (final BadLocationException e) {
        }
    }
View Full Code Here

            removeHighlights(textComp);
        }

        try {
            final Highlighter hilite = textComp.getHighlighter();
            hilite.addHighlight(pos, pos+len, myHighlightPainter);
        } catch (final BadLocationException e) {
        }
    }

    // Removes only our private highlights
View Full Code Here

  protected void highlight(JTextComponent comp, int i, int j) {
    Highlighter highlighter = comp.getHighlighter();
    highlighter.removeAllHighlights();

    try {
      highlighter.addHighlight(i, j+1, DefaultHighlighter.DefaultPainter);
    }
    catch (BadLocationException ble) {
      errMgr.internalError(tmodel.root.event.scope.st, "bad highlight location", ble);
    }
  }
View Full Code Here

        text = text.toUpperCase();
        pattern = pattern.toUpperCase();
        int pos = textComp.getCaretPosition();
        if ((pos = text.indexOf(pattern, pos)) != -1)
          if (findAll == 0) {
            hilite.addHighlight(pos, pos + pattern.length(), myHighlightPainter);
            textComp.setCaretPosition(pos + pattern.length());
            textComp.setSelectionStart(pos);
            textComp.setSelectionEnd(pos + pattern.length());
          } else {
            for (; (pos = text.indexOf(pattern, pos)) >= 0; pos += pattern.length())
View Full Code Here

            textComp.setCaretPosition(pos + pattern.length());
            textComp.setSelectionStart(pos);
            textComp.setSelectionEnd(pos + pattern.length());
          } else {
            for (; (pos = text.indexOf(pattern, pos)) >= 0; pos += pattern.length())
              hilite.addHighlight(pos, pos + pattern.length(), myHighlightPainter);

          }
      } catch (BadLocationException badlocationexception) {
      }
  }
View Full Code Here

    highlighter.removeAllHighlights();

    try {
      i = toComponentPosition(comp, i);
      j = toComponentPosition(comp, j);
      highlighter.addHighlight(i, j+1, DefaultHighlighter.DefaultPainter);
      if (scroll) {
        if (comp.getCaretPosition() < i || comp.getCaretPosition() > j) {
          comp.moveCaretPosition(i);
          comp.scrollRectToVisible(comp.modelToView(i));
        }
View Full Code Here

            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

        // parameters.
        tc.replaceSelection(sb.toString());
        for (int i=0; i<paramCount; i++) {
          Point pt = (Point)paramLocs.get(i);
           // "-1" is a workaround for Java Highlight issues.
          tags.add(h.addHighlight(pt.x-1, pt.y, p));
        }

        // Go back and start at the first parameter.
        tc.setCaretPosition(dot);
        if (pc.getParamCount()>0) {
View Full Code Here

       
        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

TOP
Copyright © 2018 www.massapi.com. 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.