javax.swing.text.JTextComponent.setForeground()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(132)

本文整理了Java中javax.swing.text.JTextComponent.setForeground()方法的一些代码示例,展示了JTextComponent.setForeground()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextComponent.setForeground()方法的具体详情如下:
包路径:javax.swing.text.JTextComponent
类名称:JTextComponent
方法名:setForeground

JTextComponent.setForeground介绍

暂无

代码示例

代码示例来源:origin: geotools/geotools

public boolean validate() {
    String txt = text.getText();
    if (txt.length() == 0) {
      return true;
    }
    Object value = Converters.convert(txt, parameter.type);
    if (value == null) {
      text.setToolTipText("Could not create " + parameter.type);
      text.setForeground(Color.RED);
      return false;
    } else {
      text.setToolTipText(null);
      text.setForeground(Color.BLACK);
      return true;
    }
  }
}

代码示例来源:origin: com.l2fprod.common/l2fprod-common-shared

public void setSubtitleColor(Color color) {
 subtitleLabel.setForeground(color);
}

代码示例来源: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: org.geotools/gt-swing

public boolean validate() {
  String txt = text.getText();
  if (txt.length() == 0) {
    return true;
  }
  Object value = Converters.convert(txt, parameter.type);
  if (value == null) {
    text.setToolTipText( "Could not create "+parameter.type );
    text.setForeground(Color.RED);
    return false;
  } else {
    text.setToolTipText(null);
    text.setForeground(Color.BLACK);
    return true;
  }
}

代码示例来源:origin: zgqq/mah

@Override
public void apply(LayoutTheme theme) {
  if (theme instanceof SwingLayoutTheme) {
    SwingLayoutTheme layoutTheme = (SwingLayoutTheme) theme;
    String panelBackgroundColor = layoutTheme.findProperty("background-color");
    panel.setBackground(Color.decode(panelBackgroundColor));
    String inputFieldBackgroundColor = layoutTheme.findProperty("input-field-background-color");
    input.setBackground(Color.decode(inputFieldBackgroundColor));
    String fontColor = layoutTheme.findProperty("input-field-font-color");
    input.setForeground(Color.decode(fontColor));
    String cursorColor = layoutTheme.findProperty("input-cursor-color");
    input.setCaretColor(Color.decode(cursorColor));
  }
}

代码示例来源: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: de.sciss/prefuse-core

/**
 * Stops text editing on the display, hiding the text editing widget. If
 * the text editor was associated with a specific VisualItem (ie one of the
 * editText() methods which include a VisualItem as an argument was called),
 * the item is updated with the edited text.
 */
public void stopEditing() {
  m_editor.setVisible(false);
  if ( m_editItem != null ) {
    String txt = m_editor.getText();
    m_editItem.set(m_editAttribute, txt);
    m_editItem = null;
    m_editAttribute = null;
    m_editor.setBackground(null);
    m_editor.setForeground(null);
  }
  m_editing = false;
}

代码示例来源:origin: UNIVALI-LITE/Portugol-Studio

public static void configuraWebLaf(JTextComponent field) {
    if (!WeblafUtils.weblafEstaInstalado()) {
      return;
    }
//       ((WebTextAreaUI) field.getUI()).setDrawBorder(false);
//       ((WebTextAreaUI) field.getUI()).setDrawBackground(true);
    field.setBorder(new EmptyBorder(15,15,15,15));
    field.setOpaque(true);
    field.setBackground(ColorController.COR_DESTAQUE);
    field.setForeground(ColorController.COR_LETRA);
  }
  public static void configuraWebLaf(JProgressBar field) {

代码示例来源:origin: jsettlers/settlers-remake

/**
 * Install the border
 * 
 * @param txt
 *            Text component
 */
public static void installUi(JTextComponent txt) {
  txt.setOpaque(false);
  Insets margin = txt.getMargin();
  if (margin == null) {
    margin = new Insets(5, 5, 5, 5);
  }
  Border marginBorder = BorderFactory.createEmptyBorder(margin.top + 3, margin.left, margin.bottom + 3, margin.right);
  CompoundBorder border = new CompoundBorder(BorderFactory.createLineBorder(Color.WHITE), marginBorder);
  txt.setBorder(border);
  txt.setBackground(Color.BLUE);
  txt.setForeground(Color.WHITE);
  txt.setSelectionColor(SELECTION_COLOR);
}

代码示例来源:origin: io.ultreia.java4all.i18n/i18n-editor

private void updateTitle() {
  editor.setFont(editorFont);
  editor.setForeground(editorColor);
  setTitleFont(titleFont);
  setTitleForeground(titleColor);
  setTitle(titleText);
  setRightDecoration(model.isGlobalModified() ? rightDecoration : null);
}

代码示例来源:origin: atarw/material-ui-swing

private void installMyDefaults() {
  this.activeBackground = UIManager.getColor("TextField.selectionBackground");
  this.activeForeground = UIManager.getColor("TextField.selectionForeground");
  this.inactiveBackground = UIManager.getColor("TextField.inactiveBackground");
  this.inactiveForeground = UIManager.getColor("TextField.inactiveForeground");
  getComponent().setFont(MaterialFonts.REGULAR);
  getComponent().setSelectionColor(getComponent().hasFocus() && getComponent().isEnabled() ? activeBackground : inactiveBackground);
  getComponent().setSelectedTextColor(getComponent().hasFocus() && getComponent().isEnabled() ? activeForeground : inactiveForeground);
  getComponent().setForeground(getComponent().hasFocus() && getComponent().isEnabled() ? activeForeground : inactiveForeground);
  getComponent().setBorder(BorderFactory.createEmptyBorder(3, 5, 2,5));
}
@Override

代码示例来源:origin: threerings/tripleplay

/** Re-applies the current Field styles to the text component. */
public void validateStyles () {
  Font font = _element.resolveStyle(Style.FONT);
  _textComp.setFont(new java.awt.Font(font.name, awtFontStyle(font.style),
                    FloatMath.round(font.size)));
  Color col = new Color(_element.resolveStyle(Style.COLOR));
  _textComp.setForeground(col);
  _textComp.setCaretColor(col);
  if (isField()) {
    switch (_element.resolveStyle(Style.HALIGN)) {
    case CENTER:
      asField().setHorizontalAlignment(JTextField.CENTER);
      break;
    case LEFT:
      asField().setHorizontalAlignment(JTextField.LEFT);
      break;
    case RIGHT:
      asField().setHorizontalAlignment(JTextField.RIGHT);
      break;
    }
  }
  // TODO: Keyboard.TextType textType = resolveStyle(Field.TEXT_TYPE);
}

代码示例来源:origin: cytoscape.coreplugins/quickfind

editor.setForeground(Color.BLACK);
} else {
  if ((comboBox.getTextIndex() != null) && (comboBox.getTextIndex().getNumKeys() > 0)) {
    model.addElement(new Hit(pattern, new Object[0]));
    editor.setBackground(new Color(212, 153, 159));
    editor.setForeground(Color.WHITE);

代码示例来源:origin: de.sciss/prefuse-core

/**
 * Edit text for the given VisualItem and field. Presents a text
 * editing widget spanning the given bounding box. Use stopEditing()
 * to hide the text widget. When stopEditing() is called, the field
 * will automatically be updated with the VisualItem.
 * @param item the VisualItem to edit
 * @param attribute the attribute to edit
 * @param r Rectangle representing the desired bounding box of the text
 *  editing widget
 */
public void editText(VisualItem item, String attribute, Rectangle r) {
  if ( m_editing ) { stopEditing(); }
  String txt = item.getString(attribute);
  m_editItem = item;
  m_editAttribute = attribute;
  Color tc = ColorLib.getColor(item.getTextColor());
  Color fc = ColorLib.getColor(item.getFillColor());
  m_editor.setForeground(tc);
  m_editor.setBackground(fc);
  editText(txt, r);
}

代码示例来源:origin: org.swinglabs.swingx/swingx-all

if (txt.isFocusOwner()
    && PromptSupport.getFocusBehavior(txt) == FocusBehavior.HIGHLIGHT_PROMPT) {
  promptComponent.setForeground(txt.getSelectedTextColor());
  try {
    promptComponent.getHighlighter().addHighlight(0,
  promptComponent.setForeground(PromptSupport.getForeground(txt));

代码示例来源:origin: org.swinglabs.swingx/swingx-core

if (txt.isFocusOwner()
    && PromptSupport.getFocusBehavior(txt) == FocusBehavior.HIGHLIGHT_PROMPT) {
  promptComponent.setForeground(txt.getSelectedTextColor());
  try {
    promptComponent.getHighlighter().addHighlight(0,
  promptComponent.setForeground(PromptSupport.getForeground(txt));

代码示例来源:origin: com.haulmont.thirdparty/swingx-core

if (txt.isFocusOwner()
    && PromptSupport.getFocusBehavior(txt) == FocusBehavior.HIGHLIGHT_PROMPT) {
  promptComponent.setForeground(txt.getSelectedTextColor());
  try {
    promptComponent.getHighlighter().addHighlight(0,
  promptComponent.setForeground(PromptSupport.getForeground(txt));

代码示例来源:origin: khuxtable/seaglass

fg = style.getColorForState(context, ColorType.TEXT_FOREGROUND);
if (fg != null) {
  c.setForeground(fg);

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

editor.setForeground(plaf.getColor(prefix + ".foreground"));

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

editor.setForeground(plaf.getColor(prefix + ".foreground"));

相关文章

JTextComponent类方法