當前位置: 首頁>>代碼示例>>Java>>正文


Java Highlighter.removeAllHighlights方法代碼示例

本文整理匯總了Java中javax.swing.text.Highlighter.removeAllHighlights方法的典型用法代碼示例。如果您正苦於以下問題:Java Highlighter.removeAllHighlights方法的具體用法?Java Highlighter.removeAllHighlights怎麽用?Java Highlighter.removeAllHighlights使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.text.Highlighter的用法示例。


在下文中一共展示了Highlighter.removeAllHighlights方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: showEntry

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
/** Show an entry that has been selected. */
private void showEntry(Entry e) {
    try {
        // update simple fields
        setTitle(e.file.getName());
        checkField.setText(e.check);
        enclPanel.setInfo(e.encl);
        selfPanel.setInfo(e.self);
        // show file text with highlights
        body.setText(e.file.getCharContent(true).toString());
        Highlighter highlighter = body.getHighlighter();
        highlighter.removeAllHighlights();
        addHighlight(highlighter, e.encl, enclColor);
        addHighlight(highlighter, e.self, selfColor);
        scroll(body, getMinPos(enclPanel.info, selfPanel.info));
    } catch (IOException ex) {
        body.setText("Cannot read " + e.file.getName() + ": " + e);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:TreePosTest.java

示例2: caretUpdate

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
@Override
public void caretUpdate(CaretEvent e) {
	int cursor = e.getDot();
	JTextPane textPane = (JTextPane)e.getSource();
	TokenPositionAnalysis analysis = getAnalysisForCharIndex(cursor);
	Highlighter highlighter = textPane.getHighlighter();
	HighlightPainter painter = new DefaultHighlightPainter(Color.orange);
	try {
		highlighter.removeAllHighlights();
		if ( analysis!=null ) {
			highlighter.addHighlight(analysis.charIndexStart, analysis.charIndexStop+1, painter);
		}
		scope.injectNLConsole.setText(analysis!=null ? analysis.wsAnalysis : "");
		scope.injectNLConsole.setCaretPosition(0);
		scope.alignConsole.setText(analysis!=null ? analysis.alignAnalysis : "");
		scope.alignConsole.setCaretPosition(0);
	}
	catch (Exception ex) {
		ex.printStackTrace(System.err);
	}
}
 
開發者ID:antlr,項目名稱:codebuff,代碼行數:22,代碼來源:GUIController.java

示例3: highlight

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
protected void highlight(JTextComponent comp, int i, int j, boolean scroll) {
    Highlighter highlighter = comp.getHighlighter();
    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));
            }
        }
    }
    catch (BadLocationException ble) {
        errMgr.internalError(tmodel.root.event.scope.st, "bad highlight location", ble);
    }
}
 
開發者ID:antlr,項目名稱:codebuff,代碼行數:19,代碼來源:STViz.java

示例4: highlight

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
protected void highlight(JTextComponent comp, int i, int j, boolean scroll) {
	Highlighter highlighter = comp.getHighlighter();
	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));
			}
		}
	}
	catch (BadLocationException ble) {
		errMgr.internalError(tmodel.root.event.scope.st, "bad highlight location", ble);
	}
}
 
開發者ID:antlr,項目名稱:codebuff,代碼行數:20,代碼來源:STViz.java

示例5: highlightLocation

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
public void highlightLocation(JTextComponent textComp, String location) {
	//Highlights a single location throughout the text
	Highlighter.HighlightPainter locationHighlighter= new MyHighlighPainter(Color.cyan);
	
	try{
		Highlighter highlighter= textComp.getHighlighter();
		highlighter.removeAllHighlights();
		Document doc = textComp.getDocument();
		String text = doc.getText(0, doc.getLength()).toUpperCase();
		int size= location.length();
		LinkedList<Integer> indeces= allIndeces(text, location.toUpperCase());
		for(int i=0; i<indeces.size(); i++){
			int index=indeces.get(i);
			highlighter.addHighlight(index, index+size, locationHighlighter);
		}
	}
	catch(Exception e){
		e.printStackTrace();
	}
}
 
開發者ID:rkhatib,項目名稱:topotext,代碼行數:21,代碼來源:HighlighterImplementation.java

示例6: nextLocation

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
public void nextLocation(JTextComponent textComp, String location, int currentIndex,
		LinkedList<Integer> indexList, int size) {
	Highlighter highlighter= textComp.getHighlighter();
	highlighter.removeAllHighlights();
	highlightLocation(textComp, location);
	int index= indexList.indexOf(currentIndex);

	if(index== indexList.size()-1){
		   JOptionPane.showMessageDialog(null, "No more instances of this location");
	}
	else{
		index++;
		setCurrentLocation(indexList.get(index));
		highlightWithDistance(textComp, location, indexList.get(index), size, indexList);
	}
	
}
 
開發者ID:rkhatib,項目名稱:topotext,代碼行數:18,代碼來源:HighlighterImplementation.java

示例7: previousLocation

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
public void previousLocation(JTextComponent textComp, String location, int currentIndex,
		LinkedList<Integer> indexList, int size) {
	Highlighter highlighter= textComp.getHighlighter();
	highlighter.removeAllHighlights();
	highlightLocation(textComp, location);
	int index= indexList.indexOf(currentIndex);

	if(index== 0){
		   JOptionPane.showMessageDialog(null, "No more instances of this location");
	}
	else if(index< indexList.size()){
		index--;
		setCurrentLocation(indexList.get(index));
		//posLabel.setText(""+index);
		highlightWithDistance(textComp, location, indexList.get(index), size, indexList);
	}
	else{
		index= indexList.size()-1;
		setCurrentLocation(indexList.get(index));
	//	posLabel.setText(""+index);
		highlightWithDistance(textComp, location, indexList.get(index), size, indexList);
	}
}
 
開發者ID:rkhatib,項目名稱:topotext,代碼行數:24,代碼來源:HighlighterImplementation.java

示例8: spellCheckAllText

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
public void spellCheckAllText() throws BadLocationException {   
    Document doc = etc.getrSyntaxTextArea().getDocument();   
    if (doc != null) {                                                
        String editorText = etc.getrSyntaxTextArea().getText(0, doc.getLength());            
        if (editorText != null) {  
            Highlighter highlighter = etc.getrSyntaxTextArea().getHighlighter();                                      
            if(etc.getEditorState().isHighlighted()) {  
                List<RuleMatch> matches = null;  
                try {
                    matches = etc.getLangTool().check(editorText);
                } catch (IOException ex) {
                    Exceptions.printStackTrace(ex);
                }

                //Highlight the spelling check results
                for (RuleMatch match : matches) {
                    highlighter.addHighlight(match.getFromPos(), match.getToPos(), etc.getPainter());   
                }                        
            } else {  
                highlighter.removeAllHighlights();
            }
        }
    }        
}
 
開發者ID:sebbrudzinski,項目名稱:Open-LaTeX-Studio,代碼行數:25,代碼來源:SpellCheckService.java

示例9: highlight

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
private void highlight(Component comp, boolean cancel) {
    if (comp == bar) {
        return;
    }
    if (comp instanceof JTextPane) {
        JTextPane tcomp = (JTextPane)comp;
        if(!tcomp.isVisible()) {
            return;
        }
        String txt = tcomp.getText();
        Matcher matcher = pattern.matcher(txt);
        Highlighter highlighter = tcomp.getHighlighter();
        if (cancel) {
            highlighter.removeAllHighlights();
        } else {
            int idx = 0;
            while (matcher.find(idx)) {
                int start = matcher.start();
                int end = matcher.end();
                if (start == end) {
                    break;
                }
                try {
                    highlighter.addHighlight(start, end, highlighterAll);
                } catch (BadLocationException blex) {
                    BugtrackingManager.LOG.log(Level.INFO, blex.getMessage(), blex);
                }
                idx = matcher.end();
            }
        }
    } else if (comp instanceof Container) {
        Container cont = (Container)comp;
        for (Component subComp : cont.getComponents()) {
            highlight(subComp, cancel);
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:38,代碼來源:FindSupport.java

示例10: clearAllSnippetHighlights

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
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();
            }
        }
    }
}
 
開發者ID:freeseawind,項目名稱:littleluck,代碼行數:14,代碼來源:CodeViewer.java

示例11: highlightLocation

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
public void highlightLocation(JTextComponent textComp, String location) {
	// Highlights a single location throughout the text
	Highlighter.HighlightPainter locationHighlighter = new MyHighlighPainter(
			Color.cyan);

	try {
		Highlighter highlighter = textComp.getHighlighter();
		highlighter.removeAllHighlights();
		Document doc = textComp.getDocument();
		String text = doc.getText(0, doc.getLength()).toUpperCase();
		int size = location.length();
		LinkedList<Integer> indeces = allIndeces(text,
				location.toUpperCase());
		for (int i = 0; i < indeces.size(); i++) {
			int index = indeces.get(i);
			highlighter.addHighlight(index, index + size,
					locationHighlighter);
		}

		if (!cloudSizeField.getText().equals("")) {

			LinkedList<String> words = returnWordsIgnoringUnintersesting(
					textComp, currentLocation,
					Integer.parseInt(cloudSizeField.getText()));

			freq = new CountFrequencyImp(words);

			lblMostFrequentWord
					.setText("Most Frequent Word: " + freq.MFW());
		}

	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
開發者ID:rkhatib,項目名稱:topotext,代碼行數:36,代碼來源:Frame.java

示例12: nextLocation

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
public void nextLocation(JTextComponent textComp, String location,
		int currentIndex, LinkedList<Integer> indexList) {
	try {
		Highlighter highlighter = textComp.getHighlighter();
		highlighter.removeAllHighlights();
		highlightLocation(textComp, location);
		indexList = wordIndeces;
		int index = indexList.indexOf(currentIndex);
		if (indexForScroll < indicesForScroll.size() - 1)
			indexForScroll++;
		currentIndex = indicesForScroll.get(indexForScroll);
		if (index == indexList.size() - 1) {
			JOptionPane.showMessageDialog(null,
					"No more instances of this location");
		} else {
			index++;
			setCurrentLocation(indexList.get(index));
			textComp.setCaretPosition(currentIndex + 100);
			highlightWithDistance(textComp, location, indexList.get(index),
					size, indexList);

			LinkedList<String> words = returnWordsIgnoringUnintersesting(
					textComp, currentLocation,
					Integer.parseInt(cloudSizeField.getText()));

			freq = new CountFrequencyImp(words);

			lblMostFrequentWord
					.setText("Most Frequent Word: " + freq.MFW());
		}
	} catch (Exception e) {

	}

}
 
開發者ID:rkhatib,項目名稱:topotext,代碼行數:36,代碼來源:Frame.java

示例13: previousLocation

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
public void previousLocation(JTextComponent textComp, String location,
		int currentIndex, LinkedList<Integer> indexList) {
	try {
		Highlighter highlighter = textComp.getHighlighter();
		highlighter.removeAllHighlights();
		highlightLocation(textComp, location);
		indexList = wordIndeces;
		int index = indexList.indexOf(currentIndex);
		if (indexForScroll > 0)
			indexForScroll--;
		currentIndex = indicesForScroll.get(indexForScroll);
		if (index == 0) {
			JOptionPane.showMessageDialog(null,
					"No more instances of this location");
		} else if (index < indexList.size()) {
			index--;
			setCurrentLocation(indexList.get(index));
			textComp.setCaretPosition(currentIndex);
			highlightWithDistance(textComp, location, indexList.get(index),
					Integer.parseInt(cloudSizeField.getText()), indexList);
		} else {
			index = indexList.size() - 1;
			setCurrentLocation(indexList.get(index));
			textComp.setCaretPosition(currentIndex);
			highlightWithDistance(textComp, location, indexList.get(index),
					Integer.parseInt(cloudSizeField.getText()), indexList);

			LinkedList<String> words = returnWordsIgnoringUnintersesting(
					textComp, currentLocation,
					Integer.parseInt(cloudSizeField.getText()));

			freq = new CountFrequencyImp(words);

			lblMostFrequentWord
					.setText("Most Frequent Word: " + freq.MFW());
		}
	} catch (Exception e) {

	}
}
 
開發者ID:rkhatib,項目名稱:topotext,代碼行數:41,代碼來源:Frame.java

示例14: highlightsChanged

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
/**
 * Determines if highlights have changed.
 * Collects all the highlights and marks the presentation.
 *
 * @param e The TextHelpModelEvent.
 */
@Override
public void highlightsChanged(TextHelpModelEvent e) {
    debug("highlightsChanged " + e);

    // if we do anything with highlighting it would need to
    // be handled here.
    TextHelpModel model = theViewer.getModel();
    Highlighter highlighter = html.getHighlighter();
    highlighter.removeAllHighlights();
    for (Highlight highlight : model.getHighlights()) {
        try {
            int len = highlight.getEndOffset() - highlight.getStartOffset();
            if (len <= 0) {
                continue;
            }
            Integer[] indexes = findIndexes(textDocument.substring(highlight.getStartOffset(),
                    highlight.getEndOffset()));
            for (int i = 0; i < indexes.length; i++) {
                highlighter.addHighlight(indexes[i], indexes[i] + len, HIGHLIGHT_PAINTER);
            }
        } catch (BadLocationException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
    html.repaint();
}
 
開發者ID:mantlik,項目名稱:swingbox-javahelp-viewer,代碼行數:33,代碼來源:SwingboxContentViewerUI.java

示例15: highLight

import javax.swing.text.Highlighter; //導入方法依賴的package包/類
/**
 * Highlight words in the Textarea
 *
 * @param words to highlight
 */
private void highLight() {
    // highlight all characters that appear in charsToHighlight
    Highlighter highlighter = getHighlighter();
    highlighter.removeAllHighlights();

    if ((highlightPattern == null) || !highlightPattern.isPresent()) {
        return;
    }
    String content = getText();
    if (content.isEmpty()) {
        return;
    }

    highlightPattern.ifPresent(pattern -> {
        Matcher matcher = pattern.matcher(content);
        while (matcher.find()) {
            try {
                highlighter.addHighlight(matcher.start(), matcher.end(), DefaultHighlighter.DefaultPainter);
            } catch (BadLocationException ble) {
                // should not occur if matcher works right
                LOGGER.warn("Highlighting not possible, bad location", ble);
            }
        }
    });

}
 
開發者ID:JabRef,項目名稱:jabref,代碼行數:32,代碼來源:JTextAreaWithHighlighting.java


注:本文中的javax.swing.text.Highlighter.removeAllHighlights方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。