本文整理汇总了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
}
示例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;
}
示例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);
}
}
示例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();
}
}
}
}
示例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)
{}
}
示例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);
}
}
示例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");
}
}
示例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");
}
}
示例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");
}
}
示例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);
}
示例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);
}
}
示例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();
}
示例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();
}
示例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);
}
}
示例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);
}
}