本文整理汇总了Java中javax.swing.text.StyleConstants.setBackground方法的典型用法代码示例。如果您正苦于以下问题:Java StyleConstants.setBackground方法的具体用法?Java StyleConstants.setBackground怎么用?Java StyleConstants.setBackground使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.text.StyleConstants
的用法示例。
在下文中一共展示了StyleConstants.setBackground方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: VersioningSystemColors
import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
public VersioningSystemColors(OptionsPanelColorProvider provider) {
this.colors = provider.getColors();
if (colors == null) {
throw new NullPointerException("Null colors for " + provider); // NOI18N
}
this.provider = provider;
// initialize saved colors list
savedColorAttributes = new ArrayList<AttributeSet>(colors.size());
for (Map.Entry<String, Color[]> e : colors.entrySet()) {
SimpleAttributeSet sas = new SimpleAttributeSet();
StyleConstants.setBackground(sas, e.getValue()[0]);
sas.addAttribute(StyleConstants.NameAttribute, e.getKey());
sas.addAttribute(EditorStyleConstants.DisplayName, e.getKey());
savedColorAttributes.add(sas);
}
}
示例2: addHighlight
import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
void addHighlight (StyledDocument doc, int line1, int line2, final java.awt.Color color) {
if (line1 > 0) {
--line1;
}
SimpleAttributeSet attrs = new SimpleAttributeSet();
StyleConstants.setBackground(attrs, color);
attrs.addAttribute(HighlightsContainer.ATTR_EXTENDS_EOL, Boolean.TRUE);
int startOffset = getRowStartFromLineOffset(doc, line1);
int endOffset = getRowStartFromLineOffset(doc, line2);
synchronized (highlights) {
ListIterator<HighLight> it = highlights.listIterator();
HighLight toAdd = new HighLight(startOffset, endOffset, attrs);
while (it.hasNext()) {
HighLight highlight = it.next();
if (highlight.contains(startOffset)) {
it.remove();
break;
} else if (highlight.precedes(startOffset)) {
it.previous();
break;
}
}
it.add(toAdd);
}
fireHilitingChanged();
}
示例3: editLyrics
import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
/**
* Description of the Method
*/
public void editLyrics() {
if (lyricsArea.isEditable()) {
return;
}
if (initialBlinkRate < 0) {
initialBlinkRate = lyricsArea.getCaret().getBlinkRate();
}
lyricsArea.requestFocus();
lyricsArea.setEditable(true);
StyleConstants.setBackground(
notSelectStyle,
nofontBG);
lyricsArea.getCaret().setVisible(true);
lyricsArea.getCaret().setBlinkRate(initialBlinkRate);
lyricsArea.getStyledDocument().setCharacterAttributes(0,
lyricsArea.getStyledDocument().getLength(), notSelectStyle,
false);
tableSelectionListener.valueChanged(null);
}
示例4: finishEditing
import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
/**
* Description of the Method
*/
public void finishEditing() {
if (initialBlinkRate < 0) {
initialBlinkRate = lyricsArea.getCaret().getBlinkRate();
}
lyricsArea.setEditable(false);
StyleConstants.setBackground(
notSelectStyle,
nofontBG);
lyricsArea.getCaret().setVisible(true);
lyricsArea.getCaret().setBlinkRate(0);
lyricsArea.getStyledDocument().setCharacterAttributes(0,
lyricsArea.getStyledDocument().getLength(), notSelectStyle,
false);
// if (spellCheckerComp != null) {
// spellCheckerComp.getHandler().markupSpelling(lyricsArea);
// }
}
示例5: DocumentHandler
import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
/**
* Constructor
*
* @param textPane
*/
public DocumentHandler(JTextPane textPane) {
this.textPane = textPane;
setFormatter(new RecordFormatter());
StyledDocument document = (StyledDocument) this.textPane.getDocument();
infoStyle = document.addStyle("INFO", null);
StyleConstants.setFontFamily(infoStyle, "Monospaced");
StyleConstants.setBackground(infoStyle, Color.white);
StyleConstants.setForeground(infoStyle, Color.blue);
severStyle = document.addStyle("SEVER", null);
StyleConstants.setFontFamily(severStyle, "Monospaced");
StyleConstants.setBackground(severStyle, Color.white);
StyleConstants.setForeground(severStyle, Color.red);
}
示例6: RevisionRenderer
import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
public RevisionRenderer () {
selectionBackground = new JList().getSelectionBackground();
selectionForeground = new JList().getSelectionForeground();
selectedStyle = addStyle("selected", null); // NOI18N
StyleConstants.setForeground(selectedStyle, selectionForeground); // NOI18N
StyleConstants.setBackground(selectedStyle, selectionBackground); // NOI18N
normalStyle = addStyle("normal", null); // NOI18N
StyleConstants.setForeground(normalStyle, UIManager.getColor("List.foreground")); // NOI18N
setLayout(new BorderLayout());
setBorder(null);
}
示例7: getColorAttributes
import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
public synchronized List<AttributeSet> getColorAttributes() {
ArrayList<AttributeSet> attrs = this.colorAttributes;
if (attrs == null) {
attrs = new ArrayList<AttributeSet>(colors.size());
for (Map.Entry<String, Color[]> e : colors.entrySet()) {
SimpleAttributeSet sas = new SimpleAttributeSet ();
StyleConstants.setBackground(sas, e.getValue()[0]);
sas.addAttribute(StyleConstants.NameAttribute, e.getKey());
sas.addAttribute(EditorStyleConstants.DisplayName, e.getKey());
attrs.add(sas);
}
this.colorAttributes = attrs;
}
return attrs;
}
示例8: createSelectedStyle
import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
private Style createSelectedStyle (JTextPane textPane) {
Style selectedStyle = textPane.addStyle("selected", null); //NOI18N
StyleConstants.setForeground(selectedStyle, selectionForeground);
StyleConstants.setBackground(selectedStyle, selectionBackground);
return selectedStyle;
}
示例9: addToConsole
import javax.swing.text.StyleConstants; //导入方法依赖的package包/类
private void addToConsole(LogEntry logentry, boolean update) {
StyledDocument doc = console.textpane.getStyledDocument();
Style style = doc.addStyle("Style", null);
if(update) {
updateLogEntry(logentry);
}
boolean doesLog = true;
switch(logentry.getLevel()) {
case LogEntry.LEVELERROR:
doesLog = showError;
StyleConstants.setBackground(style, Color.WHITE);
StyleConstants.setForeground(style, Color.red);
break;
case LogEntry.LEVELINPUT:
doesLog = showInput;
StyleConstants.setBackground(style, Color.WHITE);
StyleConstants.setForeground(style, Color.BLUE);
break;
case LogEntry.LEVELLOW:
doesLog = showLow;
StyleConstants.setBackground(style, Color.WHITE);
StyleConstants.setForeground(style, Color.GRAY);
break;
case LogEntry.LEVELNORMAL:
doesLog = showNormal;
StyleConstants.setBackground(style, Color.WHITE);
StyleConstants.setForeground(style, Color.BLACK);
break;
case LogEntry.LEVELCOMMAND:
doesLog = showCommand;
StyleConstants.setBackground(style, Color.BLACK);
StyleConstants.setForeground(style, Color.YELLOW);
break;
}
if(doesLog) {
try {
doc.insertString(doc.getLength(), logentry.toString() + "\n", style);
} catch (Exception ex) {
logErr(String.format(lang.getProperty("error_while_adding_to_the_console", "Error while adding to the console: %s"), ex));
}
console.textpane.setCaretPosition(doc.getLength());
}
}