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

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

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

JTextField.setForeground介绍

暂无

代码示例

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

private void uiStyle () {
  content.setBackground(new Color(36, 36, 36));
  content.setForeground(new Color(255, 255, 255));
  bottomPanel.setBackground(new Color(36, 36, 36));
  bottomPanel.setForeground(new Color(255, 255, 255));
  buttonPanel.setBackground(new Color(36, 36, 36));
  buttonPanel.setForeground(new Color(255, 255, 255));
  linkText.setForeground(new Color(20, 150, 20));
  contentPane.setBackground(new Color(36, 36, 36));
  Border line = BorderFactory.createLineBorder(new Color(80, 80, 80));
  Border empty = new EmptyBorder(4, 4, 4, 4);
  CompoundBorder border = new CompoundBorder(line, empty);
  mavenTextField.setBorder(border);
  mavenTextField.setCaretColor(new Color(255, 255, 255));
  mavenTextField.setBackground(new Color(46, 46, 46));
  mavenTextField.setForeground(new Color(255, 255, 255));
}

代码示例来源:origin: kiegroup/optaplanner

public void refreshScoreField(Score score) {
  scoreField.setForeground(determineScoreFieldForeground(score));
  scoreField.setText("Latest best score: " + score);
}

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

@Override
public void focusGained(FocusEvent e)
{
  displayInput.getTextField().setForeground(INACTIVE_CLOCK_COLOR);
  displayInput.getTextField().selectAll();
}

代码示例来源:origin: kiegroup/optaplanner

private void updateTotals(int usedCpuPower, int usedMemory, int usedNetworkBandwidth, boolean used) {
  computerLabel.setEnabled(used);
  cpuPowerField.setText(usedCpuPower + " GHz / " + getComputerCpuPower() + " GHz");
  cpuPowerField.setForeground(usedCpuPower > getComputerCpuPower() ? TangoColorFactory.SCARLET_3 : Color.BLACK);
  cpuPowerField.setEnabled(used);
  memoryField.setText(usedMemory + " GB / " + getComputerMemory() + " GB");
  memoryField.setForeground(usedMemory > getComputerMemory() ? TangoColorFactory.SCARLET_3 : Color.BLACK);
  memoryField.setEnabled(used);
  networkBandwidthField.setText(usedNetworkBandwidth + " GB / " + getComputerNetworkBandwidth() + " GB");
  networkBandwidthField.setForeground(usedNetworkBandwidth > getComputerNetworkBandwidth()
      ? TangoColorFactory.SCARLET_3 : Color.BLACK);
  networkBandwidthField.setEnabled(used);
  costField.setEnabled(used);
}

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

void updateActivityStatus()
{
  boolean isActive = clock.isActive();
  displayInput.setEditable(editable && !isActive);
  displayInput.getTextField().setForeground(isActive ? ACTIVE_CLOCK_COLOR : INACTIVE_CLOCK_COLOR);
  startPauseButton.setToolTipText(isActive ? "Pause " + clockType : "Start " + clockType);
  startPauseButton.setIcon(isActive ? ClockTabPanel.PAUSE_ICON : ClockTabPanel.START_ICON);
  if (editable && clock.getDisplayTime() == 0 && !isActive)
  {
    displayInput.getTextField().setForeground(ColorScheme.PROGRESS_ERROR_COLOR.darker());
  }
}

代码示例来源:origin: kiegroup/optaplanner

private void updateTotals() {
  boolean used = processAssignmentList.size() > 0;
  machineLabel.setEnabled(used);
  for (MrResource resource : resourceList) {
    JTextField resourceField = resourceFieldMap.get(resource);
    long maximumCapacity;
    long safetyCapacity;
    if (machine != null) {
      MrMachineCapacity machineCapacity = machine.getMachineCapacity(resource);
      maximumCapacity = machineCapacity.getMaximumCapacity();
      safetyCapacity = machineCapacity.getSafetyCapacity();
    } else {
      maximumCapacity = 0L;
      safetyCapacity = 0L;
    }
    long usedTotal = 0L;
    for (MrProcessAssignment processAssignment : processAssignmentList) {
      usedTotal += processAssignment.getProcess().getProcessRequirement(resource).getUsage();
    }
    resourceField.setText(usedTotal + " / " + maximumCapacity);
    resourceField.setForeground(usedTotal > maximumCapacity ? TangoColorFactory.SCARLET_3 :
        (usedTotal > safetyCapacity ? TangoColorFactory.ORANGE_3 : Color.BLACK));
    resourceField.setEnabled(used);
  }
  numberOfProcessesLabel.setText(processAssignmentList.size() + " processes ");
  numberOfProcessesLabel.setEnabled(used);
}

代码示例来源:origin: kiegroup/optaplanner

scoreField = new JTextField("Score:");
scoreField.setEditable(false);
scoreField.setForeground(Color.BLACK);
scoreField.setBorder(BorderFactory.createLoweredBevelBorder());
scorePanel.add(scoreField, BorderLayout.CENTER);

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

nameInput.setBackground(ColorScheme.DARKER_GRAY_COLOR);
nameInput.setPreferredSize(new Dimension(0, 24));
nameInput.getTextField().setForeground(Color.WHITE);
nameInput.getTextField().setBorder(new EmptyBorder(0, 8, 0, 0));

代码示例来源:origin: magefree/mage

btnGenDeck.addActionListener(evt -> btnGenDeckActionPerformed(evt));
txtTimeRemaining.setEditable(false);
txtTimeRemaining.setForeground(java.awt.Color.red);
txtTimeRemaining.setHorizontalAlignment(javax.swing.JTextField.CENTER);
txtTimeRemaining.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

代码示例来源:origin: magefree/mage

txtTimeRemaining.setForeground(java.awt.Color.red);
txtTimeRemaining.setHorizontalAlignment(javax.swing.JTextField.CENTER);
txtTimeRemaining.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

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

hexField = new JTextField();
hexField.setFont(Theme.SMALL_BOLD_FONT);
hexField.setForeground(Theme.TEXT_NORMAL_COLOR);
hexField.setHorizontalAlignment(JTextField.CENTER);
hexField.setBackground(null);

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

/**
 * Sets the foreground
 *
 * @param fg
 *            the foreground
 */
@Override
public void setForeground(final Color fg) {
  if (textField != null) {
    textField.setForeground(fg);
  }
}

代码示例来源:origin: stackoverflow.com

spinner.addChangeListener(new ChangeListener() {

  @Override
  public void stateChanged(ChangeEvent e) {

  try {
    String colorString = (String)spinner.getValue();

    Field field = Class.forName("java.awt.Color").getField(colorString.toLowerCase()); // toLowerCase because the color fields are RED or red, not Red
    Color color = (Color)field.get(null);

    JTextField tf = ((JSpinner.DefaultEditor) spinner.getEditor()).getTextField();
    tf.setForeground(color);

    } catch (Exception ex) { // handle ex }
  }
});

代码示例来源:origin: igniterealtime/Spark

public void focusGained(FocusEvent e) {
  if (searchField.getText().equals(Res.getString("message.search.for.history"))) {
    searchField.setText("");
  }
  searchField.setForeground((Color) UIManager
      .get("TextField.foreground"));
}

代码示例来源:origin: igniterealtime/Spark

public void focusLost(FocusEvent e) {
    searchField.setForeground((Color) UIManager
        .get("TextField.lightforeground"));
    if (searchField.getText().length() <= 1) {
      searchField.setText(Res.getString("message.search.for.history"));
    }
  }
});

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

/**
 * here: set textfield colors to normal.
 */
@Override
protected void showFoundMessage() {
  //JW: quick hack around #487-swingx - NPE in setSearchable
  if (searchField ==  null) return;
  searchField.setBackground(previousBackgroundColor);
  searchField.setForeground(previousForegroundColor);
}

代码示例来源:origin: undera/jmeter-plugins

private void setJTextFieldColor(final JTextField tf, boolean isFloat) {
  if(!isFloat && (getIntValue(tf) > -1 || isVariableValue(tf))) {
    tf.setForeground(Color.black);
  } else if(isFloat && (getFloatValue(tf) > -1 || isVariableValue(tf))) {
    tf.setForeground(Color.black);
  } else {
    tf.setForeground(Color.red);
  }
}

代码示例来源:origin: igniterealtime/Spark

public void mouseClicked(MouseEvent e) {
    if (newSearch) {
      findField.setText("");
      findField.getTextComponent().setForeground((Color) UIManager.get("TextField.foreground"));
      newSearch = false;
    }
  }
});

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

@Override
public void setForeground(Color color) {
  if(renderer == null)
  super.setForeground(color);
  else {
    renderer.setForeground(color);
    textField.setForeground(color);
  }
}

代码示例来源:origin: igniterealtime/Spark

public void focusLost(FocusEvent e) {
    findField.getTextComponent().setForeground((Color) UIManager.get("TextField.lightforeground"));
    findField.setText(searchable.getDefaultText());
  }
});

相关文章

JTextField类方法