本文整理了Java中javax.swing.text.JTextComponent.getForeground()
方法的一些代码示例,展示了JTextComponent.getForeground()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextComponent.getForeground()
方法的具体详情如下:
包路径:javax.swing.text.JTextComponent
类名称:JTextComponent
方法名:getForeground
暂无
代码示例来源:origin: ron190/jsql-injection
default void drawPlaceholder(JTextComponent textComponent, Graphics g, String placeholderText) {
int w = textComponent.getWidth();
((Graphics2D) g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
Insets ins = textComponent.getInsets();
FontMetrics fm = g.getFontMetrics();
int c0 = textComponent.getBackground().getRGB();
int c1 = textComponent.getForeground().getRGB();
int m = 0xfefefefe;
int c2 = ((c0 & m) >>> 1) + ((c1 & m) >>> 1);
g.setColor(new Color(c2, true));
g.setFont(textComponent.getFont().deriveFont(Font.ITALIC));
g.drawString(
placeholderText,
textComponent.getComponentOrientation() == ComponentOrientation.RIGHT_TO_LEFT
? w - (fm.stringWidth(placeholderText) + ins.left + 2)
: ins.left + 2,
fm.getAscent() + 2
);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mercurial
private Color foregroundColor() {
if (textComponent != null) {
return textComponent.getForeground();
}
return foregroundColor;
}
代码示例来源:origin: com.l2fprod.common/l2fprod-common-shared
public Color getSubtitleColor() {
return subtitleLabel.getForeground();
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-editor-fold-nbui
private Color getForegroundColor() {
if (foldingColors == null) {
return textComponent.getForeground();
}
Object bgColorObj = foldingColors.getAttribute(StyleConstants.Foreground);
if (bgColorObj instanceof Color) {
return (Color)bgColorObj;
} else {
return textComponent.getForeground();
}
}
代码示例来源:origin: org.netbeans.api/org-netbeans-spi-quicksearch
public void setNoResults (boolean areNoResults) {
// no op when called too soon
if (command == null || origForeground == null) {
return;
}
// don't alter color if showing hint already
if (command.getForeground().equals(command.getDisabledTextColor())) {
return;
}
command.setForeground(areNoResults ? Color.RED : origForeground);
}
代码示例来源:origin: crashinvaders/gdx-texture-packer-gui
@Override
protected void paintSafely(Graphics g) {
super.paintSafely(g);
JTextComponent comp = getComponent();
if (hint != null && comp.getText().length() == 0 && (!(hideOnFocus && comp.hasFocus()))) {
if (color != null) {
g.setColor(color);
} else {
g.setColor(comp.getForeground().brighter().brighter().brighter());
}
Insets margin = comp.getMargin();
g.drawString(hint, margin.left + 2, margin.top + comp.getFont().getSize() + 1);
}
}
代码示例来源:origin: mucommander/mucommander
@Override
protected void paintSafely(Graphics g) {
super.paintSafely(g);
JTextComponent comp = getComponent();
if(hint!=null && comp.getText().length() == 0 && (!(hideOnFocus && comp.hasFocus()))){
if(color != null) {
g.setColor(color);
} else {
g.setColor(comp.getForeground().brighter().brighter().brighter());
}
int padding = (comp.getHeight() - comp.getFont().getSize())/2;
g.drawString(hint, 3, comp.getHeight()-padding-1);
}
}
代码示例来源:origin: crashinvaders/gdx-texture-packer-gui
@Override
protected void paintSafely(Graphics g) {
super.paintSafely(g);
JTextComponent comp = getComponent();
if (hint != null && comp.getText().length() == 0 && (!(hideOnFocus && comp.hasFocus()))) {
if (color != null) {
g.setColor(color);
} else {
g.setColor(comp.getForeground().brighter().brighter().brighter());
}
Insets margin = comp.getMargin();
int padding = (comp.getHeight() - comp.getFont().getSize()) / 2;
//TODO Apply vertical margin as well
g.drawString(hint, margin.left + 2, comp.getHeight() - padding - 1);
}
}
代码示例来源:origin: org.netbeans.api/org-netbeans-spi-quicksearch
private void setShowHint (boolean showHint) {
// remember orig color on first invocation
if (origForeground == null) {
origForeground = command.getForeground();
}
if (showHint) {
command.setForeground(command.getDisabledTextColor());
Category evalCat = CommandEvaluator.getEvalCat();
if (evalCat != null && !CommandEvaluator.isCatTemporary()) {
command.setText(getHintText(evalCat));
} else {
command.setText(getHintText(null));
}
} else {
command.setForeground(origForeground);
command.setText("");
}
}
代码示例来源:origin: semuxproject/semux-core
public TextPrompt(String text, JTextComponent component, Show show) {
this.component = component;
setShow(show);
document = component.getDocument();
setText(text);
setFont(component.getFont());
setForeground(component.getForeground());
setBorder(new EmptyBorder(component.getInsets()));
setHorizontalAlignment(JLabel.LEADING);
component.addFocusListener(this);
document.addDocumentListener(this);
component.setLayout(new BorderLayout());
component.add(this);
checkForPrompt();
}
代码示例来源:origin: SKCraft/SKMCLauncher
public TextPrompt(String text, JTextComponent component, Show show) {
this.component = component;
setShow(show);
document = component.getDocument();
setText(text);
setFont(component.getFont());
setForeground(component.getForeground());
setBorder(new EmptyBorder(component.getInsets()));
setHorizontalAlignment(JLabel.LEADING);
component.addFocusListener(this);
document.addDocumentListener(this);
component.setLayout(new BorderLayout());
component.add(this);
checkForPrompt();
}
代码示例来源:origin: org.netbeans.api/org-jruby
StyleConstants.setBackground(messageStyle, area.getForeground());
StyleConstants.setForeground(messageStyle, area.getBackground());
append(message, messageStyle);
代码示例来源:origin: nz.ac.waikato.cms.weka.thirdparty/bounce
/**
* Invalidates the scanner, to make sure a new range is set later.
*
* @param g
* the graphics context.
* @param a
* the shape.
* @see View#paint(Graphics g, Shape a)
*/
public void paint(Graphics g, Shape a) {
JTextComponent component = (JTextComponent) getContainer();
Highlighter highlighter = component.getHighlighter();
Color unselected = component.isEnabled() ? component.getForeground() : component.getDisabledTextColor();
Caret caret = component.getCaret();
selected = !caret.isSelectionVisible() || highlighter == null ? unselected : component.getSelectedTextColor();
super.paint(g, a);
scanner.setValid(false);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-gsf-testrunner-ui
@Override
public void paint(Graphics g, Shape a) {
((Graphics2D) g).addRenderingHints(getHints());
Container container = getContainer();
if (container instanceof JTextComponent) {
final JTextComponent textComp = (JTextComponent) container;
selStart = textComp.getSelectionStart();
selEnd = textComp.getSelectionEnd();
unselectedFg = textComp.isEnabled()
? textComp.getForeground()
: textComp.getDisabledTextColor();
selectedFg = textComp.getCaret().isSelectionVisible()
? textComp.getSelectedTextColor()
: unselectedFg;
}
super.paint(g, a);
}
代码示例来源:origin: nz.ac.waikato.cms.weka.thirdparty/bounce
sel0 = host.getSelectionStart();
sel1 = host.getSelectionEnd();
unselected = (host.isEnabled()) ? host.getForeground() : host.getDisabledTextColor();
Caret c = host.getCaret();
selected = c.isSelectionVisible() ? host.getSelectedTextColor() : unselected;
代码示例来源:origin: khuxtable/seaglass
Color fg = c.getForeground();
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
Color fg = editor.getForeground();
if ((fg == null) || (fg instanceof UIResource)) {
editor.setForeground(plaf.getColor(prefix + ".foreground"));
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
Color fg = editor.getForeground();
if ((fg == null) || (fg instanceof UIResource)) {
editor.setForeground(plaf.getColor(prefix + ".foreground"));
内容来源于网络,如有侵权,请联系作者删除!