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


Java DefaultHighlighter.DefaultHighlightPainter方法代碼示例

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


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

示例1: FindSupport

import javax.swing.text.DefaultHighlighter; //導入方法依賴的package包/類
private FindSupport(TopComponent tc) {
    this.tc = tc;
    bar = new FindBar(this);
    ActionMap actionMap = tc.getActionMap();
    CallbackSystemAction a = SystemAction.get(org.openide.actions.FindAction.class);
    actionMap.put(a.getActionMapKey(), new FindAction(true));
    actionMap.put(FIND_NEXT_ACTION, new FindAction(true));
    actionMap.put(FIND_PREVIOUS_ACTION, new FindAction(false));
    // Hack ensuring the same shortcuts as editor
    JEditorPane pane = new JEditorPane();
    for (Action action : pane.getEditorKitForContentType("text/x-java").getActions()) { // NOI18N
        Object name = action.getValue(Action.NAME);
        if (FIND_NEXT_ACTION.equals(name) || FIND_PREVIOUS_ACTION.equals(name)) {
            reuseShortcut(action);
        }
    }
    // PENDING the colors below should not be hardcoded
    highlighterAll = new DefaultHighlighter.DefaultHighlightPainter(new Color(255,180,66));
    highlighterCurrent = new DefaultHighlighter.DefaultHighlightPainter(new Color(176,197,227));
    pattern = Pattern.compile("$^"); // NOI18N
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:FindSupport.java

示例2: useSelectedTextColor

import javax.swing.text.DefaultHighlighter; //導入方法依賴的package包/類
/**
 * Determines whether the SelectedTextColor should be used for painting text
 * foreground for the specified highlight.
 *
 * Returns true only if the highlight painter for the specified highlight
 * is the swing painter (whether inner class of javax.swing.text.DefaultHighlighter
 * or com.sun.java.swing.plaf.windows.WindowsTextUI) and its background color
 * is null or equals to the selection color of the text component.
 *
 * This is a hack for fixing both bugs 4761990 and 5003294
 */
public static boolean useSelectedTextColor(Highlighter.Highlight h, JTextComponent c) {
    Highlighter.HighlightPainter painter = h.getPainter();
    String painterClass = painter.getClass().getName();
    if (painterClass.indexOf("javax.swing.text.DefaultHighlighter") != 0 &&
            painterClass.indexOf("com.sun.java.swing.plaf.windows.WindowsTextUI") != 0) {
        return false;
    }
    try {
        DefaultHighlighter.DefaultHighlightPainter defPainter =
                (DefaultHighlighter.DefaultHighlightPainter) painter;
        if (defPainter.getColor() != null &&
                !defPainter.getColor().equals(c.getSelectionColor())) {
            return false;
        }
    } catch (ClassCastException e) {
        return false;
    }
    return true;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:31,代碼來源:SwingUtilities2.java

示例3: highlightText

import javax.swing.text.DefaultHighlighter; //導入方法依賴的package包/類
/**
 * Highlights the words of the given text in HTML pane.
 */
private void highlightText(String highlightedText)
{
	DefaultHighlighter.DefaultHighlightPainter highlightPainter = new DefaultHighlighter.DefaultHighlightPainter(
			new Color(255, 204, 51));
	this.helpEditorPane.getHighlighter().removeAllHighlights();
	if (highlightedText != null)
	{
		ArrayList<String> highlightedWords = new ArrayList<String>();
		for (String highlightedWord : highlightedText.split("\\s"))
		{
			if (highlightedWord.length() > 0)
			{
				highlightedWords.add(highlightedWord);
			}
		}
		highlightWords(this.helpEditorPane.getDocument().getDefaultRootElement(),
				highlightedWords.toArray(new String[highlightedWords.size()]), highlightPainter);
	}
}
 
開發者ID:valsr,項目名稱:SweetHome3D,代碼行數:23,代碼來源:HelpPane.java

示例4: highlightErrorLines

import javax.swing.text.DefaultHighlighter; //導入方法依賴的package包/類
/**
 * Highlights the lines of the original file that contain detected errors.
 */
private void highlightErrorLines() {

	String text = originalFileDisplayTextArea.getText();
	String[] lines = text.split("\n");
	for (int i = 0; i < lines.length; i++)
	{
		if (lines[i].contains(" <ERROR #"))
		{
			try
			{
				int startIndex = originalFileDisplayTextArea.getLineStartOffset(i);
				int endIndex = originalFileDisplayTextArea.getLineEndOffset(i);
				Highlighter.HighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(new Color(250, 170, 170));
				originalFileDisplayTextArea.getHighlighter().addHighlight(startIndex, endIndex, painter);
			}
			catch (BadLocationException ex)
			{
				ex.printStackTrace();
			}
		}
	}
}
 
開發者ID:petebrew,項目名稱:fhaes,代碼行數:26,代碼來源:ErrorDisplayPanel.java

示例5: extraHighlight

import javax.swing.text.DefaultHighlighter; //導入方法依賴的package包/類
/**
 * Highlightet den Textbereich zwischen pos1 und pos2
 * 
 * @param pos1
 * @param pos2
 * 
 * @author Christoph Lutz (D-III-ITD-5.1)
 */
private void extraHighlight(int pos1, int pos2)
{
  Highlighter hl = compo.getHighlighter();
  try
  {
    if (extraHighlightTag == null)
    {
      Highlighter.HighlightPainter hp =
        new DefaultHighlighter.DefaultHighlightPainter(new Color(0xddddff));
      extraHighlightTag = hl.addHighlight(pos1, pos2, hp);
    }
    else
      hl.changeHighlight(extraHighlightTag, pos1, pos2);
  }
  catch (BadLocationException e1)
  {}
}
 
開發者ID:WollMux,項目名稱:WollMux,代碼行數:26,代碼來源:TextComponentTags.java

示例6: setCSVFileHighlight

import javax.swing.text.DefaultHighlighter; //導入方法依賴的package包/類
public void setCSVFileHighlight(final int number) {
	if (logger.isTraceEnabled()) {
		logger.trace("setCSVFileHighlight()");
	}
	try {
		csvFileTextArea.getHighlighter().removeAllHighlights();
		if (number >= 0) {
			final int lineStart = csvFileTextArea.getLineStartOffset(number);
			final int lineEnd = csvFileTextArea.getLineEndOffset(csvFileRowCount-1);
			final HighlightPainter painter = new DefaultHighlighter.
					DefaultHighlightPainter(
							Constants.DEFAULT_HIGHLIGHT_COLOR);
			csvFileTextArea.getHighlighter().addHighlight(lineStart, lineEnd, painter);
		}
	} catch (final BadLocationException e1) {
		logger.error("Exception thrown: " + e1.getMessage(), e1);
	}
}
 
開發者ID:52North,項目名稱:sos-importer,代碼行數:19,代碼來源:Step2Panel.java

示例7: colorLine

import javax.swing.text.DefaultHighlighter; //導入方法依賴的package包/類
public void colorLine(int l)
{
    Highlighter.HighlightPainter redPainter =
            new DefaultHighlighter.DefaultHighlightPainter(Color.red);
    try
    {
        System.out.println(l);
        int startIndex = jta.getLineStartOffset(l);
        int endIndex = jta.getLineEndOffset(l);
        jta.getHighlighter().addHighlight(startIndex, endIndex, redPainter);
    }
    catch (BadLocationException ble)
    {
        System.err.println("Failed coloring editor line");
    }

}
 
開發者ID:smetzlaff,項目名稱:openDLX,代碼行數:18,代碼來源:EditorFrame.java

示例8: moveCursorDown

import javax.swing.text.DefaultHighlighter; //導入方法依賴的package包/類
/*** Highlight index functions ***/

private void moveCursorDown() {
    if (currentHighlight != null) {
        textareaMessage.getHighlighter().removeHighlight(currentHighlight);
        currentHighlight = null;
    }
    
    try {
        selectIndex++;
        if (selectIndex >= myHighlights.size()) {
            selectIndex = 0;
        }
        SentinelHighlight nextHighlight = myHighlights.get(selectIndex);

        Highlighter.HighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(Color.GRAY);
        currentHighlight = textareaMessage.getHighlighter().addHighlight(nextHighlight.getStart()-1, nextHighlight.getEnd()+1, painter);
        
        int o = nextHighlight.getStart();
        viewMessagePart(o, false);
        labelPosition.setText(Integer.toString(selectIndex + 1) + "/" + Integer.toString(myHighlights.size()));
    } catch (BadLocationException ex) {
        BurpCallbacks.getInstance().print("CANT HIGHLIGHT1");
    }
}
 
開發者ID:dobin,項目名稱:BurpSentinel,代碼行數:26,代碼來源:PanelViewMessageUi.java

示例9: moveCursorUp

import javax.swing.text.DefaultHighlighter; //導入方法依賴的package包/類
private void moveCursorUp() {
    if (currentHighlight != null) {
        textareaMessage.getHighlighter().removeHighlight(currentHighlight);
        currentHighlight = null;
    }
    
    try {
        selectIndex--;
        if (selectIndex < 0) {
            selectIndex = myHighlights.size() - 1;
        }
        SentinelHighlight nextHighlight = myHighlights.get(selectIndex);
        
        Highlighter.HighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(Color.GRAY);
        currentHighlight = textareaMessage.getHighlighter().addHighlight(nextHighlight.getStart()-1, nextHighlight.getEnd()+1, painter);
        
        int o = nextHighlight.getStart();
        
        viewMessagePart(o, false);
        labelPosition.setText(Integer.toString(selectIndex + 1) + "/" + Integer.toString(myHighlights.size()));
    } catch (BadLocationException ex) {
        BurpCallbacks.getInstance().print("CANT HIGHLIGHT2");
    }
}
 
開發者ID:dobin,項目名稱:BurpSentinel,代碼行數:25,代碼來源:PanelViewMessageUi.java

示例10: initHighlighter

import javax.swing.text.DefaultHighlighter; //導入方法依賴的package包/類
/**
 * Initialize highlighter and painter.
 */
private void initHighlighter() {
    highlighter = new DefaultHighlighter();
    painter = new DefaultHighlighter.DefaultHighlightPainter(
            chooseHighlightColor());
    textPane.setHighlighter(highlighter);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:PatternSandbox.java

示例11: markActionPerformed

import javax.swing.text.DefaultHighlighter; //導入方法依賴的package包/類
private final void markActionPerformed(final ActionEvent evt) {
    int matches = 0;
    if (!mark.isSelected()) {
        jEditorPane1.getHighlighter().removeAllHighlights();
        return;
    }
    try {
        final Document document = jEditorPane1.getDocument();
        final String find = search.getText();
        if (find.length() == 0) {
            jEditorPane1.getHighlighter().removeAllHighlights();
            return;
        }
        for (int index = 0; index + find.length() < document.getLength(); index++) {
            final String subMatch = document.getText(index, find.length());
            if ((caseSensitive.isSelected() && find.equals(subMatch)) || (!caseSensitive.isSelected() && find.equalsIgnoreCase(subMatch))) {
                matches++;
                DefaultHighlighter.DefaultHighlightPainter highlightPainter =
                        new DefaultHighlighter.DefaultHighlightPainter(Color.orange);
                jEditorPane1.getHighlighter().addHighlight(index, index + find.length(),
                        highlightPainter);
            }
        }
        mark.setText(Translator.R("COPmark") + "(" + matches + ")");
    } catch (BadLocationException ex) {
        OutputController.getLogger().log(ex);
    }
}
 
開發者ID:GITNE,項目名稱:icedtea-web,代碼行數:29,代碼來源:ConsoleOutputPane.java

示例12: NewCSVColumnDialog

import javax.swing.text.DefaultHighlighter; //導入方法依賴的package包/類
public NewCSVColumnDialog(ViewController viewController, SPSHGPanel panel) {
	
	super(viewController.getTopFrame(), Util.I18N.getString("spshg.dialog.addnewcolumn.header"), true);
	hilit = new DefaultHighlighter();
	painter = new DefaultHighlighter.DefaultHighlightPainter(highlightColor);

	this.viewController = viewController;
	this.panel = panel;
	newCSVColumn = new CSVColumns();
	isEditMode = false;
	init();
}
 
開發者ID:3dcitydb,項目名稱:plugin-spreadsheet-generator,代碼行數:13,代碼來源:NewCSVColumnDialog.java

示例13: setupSpellCheckTool

import javax.swing.text.DefaultHighlighter; //導入方法依賴的package包/類
private void setupSpellCheckTool() {     
    painter = new DefaultHighlighter.DefaultHighlightPainter(Color.PINK);  //Default color is: PINK
    langTool = new JLanguageTool(new AmericanEnglish());    //Default Language is: American English
    for (Rule rule : langTool.getAllActiveRules()) {
        if (rule instanceof SpellingCheckRule) {
            ((SpellingCheckRule)rule).acceptPhrases(getLatexTerms());  //Accept LaText Terms from tex.cwl
            ((SpellingCheckRule)rule).acceptPhrases(Arrays.asList("documentclass", "maketitle", "tex", "TEX", "Tex"));  //Accept some TEX terms not contained in tex.cwl
        }
    }
    
    autoCheckThread = new Thread(new SpellCheckService(this));
    autoCheckThread.start();
}
 
開發者ID:sebbrudzinski,項目名稱:Open-LaTeX-Studio,代碼行數:14,代碼來源:EditorTopComponent.java

示例14: highLight

import javax.swing.text.DefaultHighlighter; //導入方法依賴的package包/類
@Override
public void highLight(JTextArea j) {
    try {
            int startIndex = j.getLineStartOffset(line - 1);
            int endIndex = j.getLineEndOffset(line-1);
            Highlighter.HighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(new Color(255, 240, 240));
            j.getHighlighter().addHighlight(startIndex, endIndex, painter);
        //    jTextArea1.geth
        } catch (BadLocationException ex) {
            Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
        }
}
 
開發者ID:software-engineering-amsterdam,項目名稱:poly-ql,代碼行數:13,代碼來源:UndefinedVariableError.java

示例15: highLight

import javax.swing.text.DefaultHighlighter; //導入方法依賴的package包/類
@Override
    public void highLight(JTextArea j) {
    try {
            int startIndex = j.getLineStartOffset(line - 1);
            int endIndex = j.getLineEndOffset(line-1);
            Highlighter.HighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(new Color(255, 240, 240));
            j.getHighlighter().addHighlight(startIndex, endIndex, painter);
        //    jTextArea1.geth
        } catch (BadLocationException ex) {
            Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
        }
}
 
開發者ID:software-engineering-amsterdam,項目名稱:poly-ql,代碼行數:13,代碼來源:InvalidOperandError.java


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