Example usage for javax.swing.text Highlighter removeAllHighlights

List of usage examples for javax.swing.text Highlighter removeAllHighlights

Introduction

In this page you can find the example usage for javax.swing.text Highlighter removeAllHighlights.

Prototype

public void removeAllHighlights();

Source Link

Document

Removes all highlights this highlighter is responsible for.

Usage

From source file:com.peterbochs.PeterBochsDebugger.java

private void jSearchObjdumpButtonActionPerformed(ActionEvent evt) {
    if (jTextField1.getText().length() > 0) {
        Highlighter h = jEditorPane1.getHighlighter();
        h.removeAllHighlights();
        String text = jEditorPane1.getText().toLowerCase();

        int nextPosition = -1;

        for (int j = 0; j < text.length() - jTextField1.getText().length() + 1; j += 1) {
            if (text.substring(j, j + jTextField1.getText().length())
                    .equals(jTextField1.getText().toLowerCase())) {
                try {
                    if (j >= jEditorPane1.getCaretPosition() && nextPosition == -1) {
                        h.addHighlight(j, j + jTextField1.getText().length(),
                                new DefaultHighlighter.DefaultHighlightPainter(Color.red));
                        nextPosition = j + jTextField1.getText().length();
                    } else {
                        h.addHighlight(j, j + jTextField1.getText().length(),
                                new DefaultHighlighter.DefaultHighlightPainter(Color.yellow));
                    }/*from   w  ww.ja va2 s .c om*/
                } catch (BadLocationException ble) {
                }
            }
        }
        if (nextPosition != -1) {
            jEditorPane1.setCaretPosition(nextPosition);
        } else {
            jEditorPane1.setCaretPosition(0);
        }
    }
}

From source file:com.peterbochs.PeterBochsDebugger.java

private void jSearchRelPltButtonActionPerformed(ActionEvent evt) {
    if (jSearchRelPltTextField.getText().length() > 0) {
        Highlighter h = jSearchRelPltEditorPane.getHighlighter();
        h.removeAllHighlights();
        String text = jSearchRelPltEditorPane.getText().toLowerCase();

        int nextPosition = -1;

        for (int j = 0; j < text.length() - jSearchRelPltTextField.getText().length() + 1; j += 1) {
            if (text.substring(j, j + jSearchRelPltTextField.getText().length())
                    .equals(jSearchRelPltTextField.getText().toLowerCase())) {
                try {
                    if (j >= jSearchRelPltEditorPane.getCaretPosition() && nextPosition == -1) {
                        h.addHighlight(j, j + jSearchRelPltTextField.getText().length(),
                                new DefaultHighlighter.DefaultHighlightPainter(Color.red));
                        nextPosition = j + jSearchRelPltTextField.getText().length();
                    } else {
                        h.addHighlight(j, j + jSearchRelPltTextField.getText().length(),
                                new DefaultHighlighter.DefaultHighlightPainter(Color.yellow));
                    }/*from  w  ww  .  ja va  2 s .com*/
                } catch (BadLocationException ble) {
                }
            }
        }
        if (nextPosition != -1) {
            jSearchRelPltEditorPane.setCaretPosition(nextPosition);
        } else {
            jSearchRelPltEditorPane.setCaretPosition(0);
        }
    }
}

From source file:com.peterbochs.PeterBochsDebugger.java

private void jSearchDynamicButtonActionPerformed(ActionEvent evt) {
    if (jSearchDynamicTextField.getText().length() > 0) {
        Highlighter h = jSearchDynamicEditorPane.getHighlighter();
        h.removeAllHighlights();
        String text = jSearchDynamicEditorPane.getText().toLowerCase();

        int nextPosition = -1;

        for (int j = 0; j < text.length() - jSearchDynamicTextField.getText().length() + 1; j += 1) {
            if (text.substring(j, j + jSearchDynamicTextField.getText().length())
                    .equals(jSearchDynamicTextField.getText().toLowerCase())) {
                try {
                    if (j >= jSearchDynamicEditorPane.getCaretPosition() && nextPosition == -1) {
                        h.addHighlight(j, j + jSearchDynamicTextField.getText().length(),
                                new DefaultHighlighter.DefaultHighlightPainter(Color.red));
                        nextPosition = j + jSearchDynamicTextField.getText().length();
                    } else {
                        h.addHighlight(j, j + jSearchDynamicTextField.getText().length(),
                                new DefaultHighlighter.DefaultHighlightPainter(Color.yellow));
                    }//from  w w  w.ja  v  a 2s  .  c om
                } catch (BadLocationException ble) {
                }
            }
        }
        if (nextPosition != -1) {
            jSearchDynamicEditorPane.setCaretPosition(nextPosition);
        } else {
            jSearchDynamicEditorPane.setCaretPosition(0);
        }
    }
}

From source file:org.monkeys.gui.matcher.MatcherPanel.java

private void clearHighlights() {
    final Highlighter h = this.textArea.getHighlighter();
    h.removeAllHighlights();
}

From source file:org.zaproxy.zap.extension.customFire.CustomFireDialog.java

/**
 * //ww  w.ja v a  2 s  . c  o m
 * @param highlightList
 * @param httpReq
 * @return JList<Highlight> 
 * Request field-HTTPMsg is highlighted based on saved list of injection points and add them to new JList<Highlight>
 */
private JList<Highlight> getSavedInjectionPointList(ArrayList highlightList, String httpReq) {

    getRequestField().setText(httpReq);

    //If list instance is null then add elements from highlightList to list or remove everything from list and add from saved highlightList
    list.clear();

    //Highlight the coords
    Highlighter highLighter = getRequestField().getHighlighter();
    highLighter.removeAllHighlights();
    HighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(Color.RED);

    for (int i = 0; i < highlightList.size(); i++) {
        String s = highlightList.get(i).toString();

        try {
            //Find co ords from string
            String[] s1 = s.split(",");
            int start = Integer.parseInt(s1[0].replaceAll("[\\D]", ""));
            int end = ((Number) NumberFormat.getInstance().parse(s1[1])).intValue();

            headerLength = httpReq.trim().length();
            urlPathStart = httpReq.indexOf("/", httpReq.indexOf("://") + 2) + 1;
            if (!(start < urlPathStart || (start < headerLength && end > headerLength))) {
                highLighter.addHighlight(start, end, painter);
                list.add(s);
            }

        } catch (BadLocationException | ParseException e) {
            e.printStackTrace();
        }

    }
    Highlight[] hls = highLighter.getHighlights();
    if (hls != null && hls.length > 0) {
        for (Highlight hl : hls) {
            injectionPointModel.addElement(hl);
        }
    }
    injectionPointList = new JList<>(injectionPointModel);
    ListCellRendererEx listCellrender = new ListCellRendererEx(getRequestField());
    injectionPointList.setCellRenderer(listCellrender);

    return injectionPointList;
}

From source file:org.zaproxy.zap.extension.httppanel.view.syntaxhighlight.HttpPanelSyntaxHighlightTextArea.java

private void removeAllHighlights() {
    Highlighter hilite = this.getHighlighter();
    hilite.removeAllHighlights();
}