Package javax.swing.text.Highlighter

Examples of javax.swing.text.Highlighter.Highlight


      setVisible(false, false);
    }

    int dot = tc.getCaretPosition();
    int selStart = tc.getSelectionStart()-1; // Workaround for Java Highlight issues.
    Highlight currentPrev = null;
    int pos = 0;
    Highlighter h = tc.getHighlighter();
    Highlight[] highlights = h.getHighlights();
    for (int i=0; i<highlights.length; i++) {
      Highlight hl = highlights[i];
      if (hl.getPainter()==p) { // Only way to identify our own highlights
        if (currentPrev==null || currentPrev.getStartOffset()>=dot ||
            (hl.getStartOffset()<selStart &&
            hl.getStartOffset()>currentPrev.getStartOffset())) {
          currentPrev = hl;
          pos = i;
        }
      }
    }
View Full Code Here


    }
    int index = -1;

    List paramHighlights = getParameterHighlights();
    for (int i=0; i<paramHighlights.size(); i++) {
      Highlight h = (Highlight)paramHighlights.get(i);
      if (dot>=h.getStartOffset() && dot<h.getEndOffset()) {
        index = i;
        break;
      }
    }
View Full Code Here

      List paramHighlights = getParameterHighlights();
      if (paramHighlights==null || paramHighlights.size()==0) {
        return null;
      }
      for (int i=0; i<paramHighlights.size(); i++) {
        Highlight h = (Highlight)paramHighlights.get(i);
        if (offs>=h.getStartOffset() && offs<=h.getEndOffset()) {
          int start = h.getStartOffset() + 1;
          int len = h.getEndOffset() - start;
          JTextComponent tc = ac.getTextComponent();
          Document doc = tc.getDocument();
          try {
            return doc.getText(start, len);
          } catch (BadLocationException ble) {
View Full Code Here

   */
  public static boolean isInHighlight(MouseEvent e, JTextField label, Highlighter h) {
    Highlight[] hls = h.getHighlights();
    if(hls == null || hls.length == 0)
      return false;
    Highlight hl = hls[0];
    FontMetrics fm = label.getFontMetrics(label.getFont());
    int offset = getCharOffset(fm, label.getText(), e.getX());
    return hl.getStartOffset() <= offset && offset < hl.getEndOffset();
  }
View Full Code Here

        final int i = element.getStartOffset();
        final int j = element.getEndOffset();
        final Highlighter highlighter = jText.getHighlighter();
        final Highlight[] highlights = highlighter.getHighlights();
        for (int k = highlights.length; --k >= 0;) {
          final Highlight highlight = highlights[k];
          final int hlStartOffset = highlight.getStartOffset();
          final int hlEndOffset = highlight.getEndOffset();
          if ((i <= hlStartOffset && hlStartOffset <= j) || (i <= hlEndOffset && hlEndOffset <= j)) {
            if (highlight.getPainter() == painter) {
              highlighter.removeHighlight(highlight);
            }
          }
        }
      }
View Full Code Here

            int i = element.getStartOffset();
            int j = element.getEndOffset();
            Highlighter highlighter = jText.getHighlighter();
            Highlight[] highlights = highlighter.getHighlights();
            for( int k = highlights.length; --k >= 0; ) {
                Highlight highlight = highlights[k];
                int hlStartOffset = highlight.getStartOffset();
                int hlEndOffset = highlight.getEndOffset();
                if( (i <= hlStartOffset && hlStartOffset <= j) ||
                    (i <= hlEndOffset && hlEndOffset <= j) ) {
                    if( highlight.getPainter() == painter ) {
                        highlighter.removeHighlight( highlight );
                    }
                }
            }
View Full Code Here

         * @param rightPad characters to pad on the right side
         */
        void padHighlights(int leftPad, int rightPad) {
           
            for (int i = 0; i < highlights.size(); i ++) {
                Highlight highlight = (Highlight)highlights.get(i);
                Highlight newHighlight = getPaddedHighlight(highlight, leftPad, rightPad);
                highlights.set(i, newHighlight);
            }
        }
View Full Code Here

         * @param leftPad characters to pad on the left side
         * @param rightPad characters to pad on the right side
         */
        void padHighlight(int highlightPos, int leftPad, int rightPad) {
            for (int i = 0; i < highlights.size(); i ++) {
                Highlight highlight = (Highlight)highlights.get(i);
                if ((highlight.getStartOffset() <= highlightPos) && (highlightPos <= highlight.getEndOffset())) {
                    Highlight newHighlight = getPaddedHighlight(highlight, leftPad, rightPad);
                    highlights.set(i, newHighlight);
                }
            }
        }
View Full Code Here

TOP

Related Classes of javax.swing.text.Highlighter.Highlight

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.