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

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

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

JComboBox.setForeground介绍

暂无

代码示例

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

box.setPreferredSize(new Dimension(box.getPreferredSize().width, 25));
box.setRenderer(new ComboBoxListRenderer());
box.setForeground(Color.WHITE);
box.setFocusable(false);
box.setPrototypeDisplayValue("XXXXXXXX"); //sorry but this is the way to keep the size of the combobox in check.

代码示例来源:origin: google/sagetv

public void setStyleSolid(boolean x)
{
 if (x)
 {
  fontStyleC.setForeground(java.awt.Color.black);
 }
 else
 {
  fontStyleC.setForeground(java.awt.Color.lightGray);
 }
}
public boolean isSizeSolid() { return fontSizeField.getBackground() == java.awt.Color.white; }

代码示例来源:origin: google/sagetv

public void setNameSolid(boolean x)
{
 if (x)
 {
  fontNameC.setForeground(java.awt.Color.black);
 }
 else
 {
  fontNameC.setForeground(java.awt.Color.lightGray);
 }
}
public void setStyleSolid(boolean x)

代码示例来源:origin: google/sagetv

public void itemStateChanged(java.awt.event.ItemEvent e)
{
 hookChoice.setForeground(java.awt.Color.black);
}

代码示例来源:origin: org.japura/japura-gui

@Override
public void setForeground(Color fg) {
 getComboBox().setForeground(fg);
}

代码示例来源:origin: google/sagetv

public void initEditingComponent()
{
 String commonValue = widgs[0].getUntranslatedName();
 boolean solid = true;
 for (int i = 1; i < widgs.length; i++)
  if (!widgs[i].getUntranslatedName().equals(commonValue))
   solid = false;
 int theIdx = java.util.Arrays.asList(Catbert.hookNames).indexOf(commonValue);
 if (theIdx != -1)
  hookChoice.setSelectedIndex(theIdx + 1); // skip the first empty choice
 if (solid)
 {
  hookChoice.setForeground(java.awt.Color.black);
 }
 else
 {
  hookChoice.setForeground(java.awt.Color.lightGray);
 }
}

代码示例来源:origin: bcdev/beam

private JComboBox<String> createInsertComboBox(final String title, final String[] patterns) {
  ArrayList<String> itemList = new ArrayList<>();
  itemList.add(title);
  itemList.addAll(Arrays.asList(patterns));
  final JComboBox<String> comboBox = new JComboBox<>(itemList.toArray(new String[itemList.size()]));
  comboBox.setFont(insertCompFont);
  comboBox.setEditable(false);
  comboBox.setForeground(insertCompColor);
  comboBox.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      if (comboBox.getSelectedIndex() != 0) {
        insertCodePattern((String) comboBox.getSelectedItem());
        comboBox.setSelectedIndex(0);
      }
    }
  });
  return comboBox;
}

代码示例来源:origin: senbox-org/snap-desktop

private JComboBox<String> createInsertComboBox(final String title, final String[] patterns) {
  ArrayList<String> itemList = new ArrayList<>();
  itemList.add(title);
  itemList.addAll(Arrays.asList(patterns));
  final JComboBox<String> comboBox = new JComboBox<>(itemList.toArray(new String[itemList.size()]));
  comboBox.setFont(insertCompFont);
  comboBox.setEditable(false);
  comboBox.setForeground(insertCompColor);
  comboBox.addActionListener(e -> {
    if (comboBox.getSelectedIndex() != 0) {
      insertCodePattern((String) comboBox.getSelectedItem());
      comboBox.setSelectedIndex(0);
    }
  });
  return comboBox;
}

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

JComboBox combo = new JComboBox(new Object[]{"Dog", "Cat", "Bird"});
combo.setBackground(Color.WHITE);
combo.setForeground(Color.BLACK);
combo.setFocusable(false);

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

class CheckBoxCellRenderer implements TableCellRenderer {
   JComboBox combo;
   JSONObject response;
   public CheckBoxCellRenderer(JComboBox comboBox) {
     this.combo = new JComboBox();
     combo.setForeground(new Color(77, 75, 71));
     for (int i = 0; i < comboBox.getItemCount(); i++) {
       combo.addItem(comboBox.getItemAt(i));
     }
     combo.addItemListener(new ItemListener() {
       @Override
       public void itemStateChanged(final ItemEvent ie) {
         System.out.println("Item state changed --");
       }
     });
   }
   public Component getTableCellRendererComponent(JTable jtable, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
     if (jtable.getSelectedRow() == row) {
       combo.setSelectedItem(value);
       combo.setActionCommand("" + row);
       return combo;
     }
     JComboBox box = new JComboBox();
     box.addItem("Pending");
     return box;
   }
 }

代码示例来源:origin: pentaho/pentaho-reporting

protected void configureEditorStyle( final Font font, final Color foreground, final Color background ) {
 comboBox.setFont( font );
 comboBox.setForeground( foreground );
 comboBox.setBackground( background );
}

代码示例来源:origin: Exslims/MercuryTrade

public JComboBox getComboBox(String[] child) {
  JComboBox comboBox = new JComboBox<>(child);
  comboBox.setBackground(AppThemeColor.HEADER);
  comboBox.setForeground(AppThemeColor.TEXT_DEFAULT);
  comboBox.setFont(BOLD_FONT.deriveFont(scale * 16f));
  comboBox.setBorder(BorderFactory.createLineBorder(AppThemeColor.BORDER, 1));
  comboBox.setUI(MercuryComboBoxUI.createUI(comboBox));
  return comboBox;
}

代码示例来源:origin: google/sagetv

public void itemStateChanged(java.awt.event.ItemEvent evt)
 {
  if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED)
  {
   if (catChoice.getForeground() != java.awt.Color.black)
   {
    catChoice.setForeground(java.awt.Color.black);
    methChoice.setForeground(java.awt.Color.black);
    catChoice.repaint();
    methChoice.repaint();
   }
   java.util.ArrayList methList = (java.util.ArrayList) Catbert.categoryMethodMap.get(evt.getItem());
   if (methList != null)
   {
    String[] methArr = (String[]) methList.toArray(new String[0]);
    java.util.Arrays.sort(methArr);
    synchronized (methChoice.getTreeLock())
    {
     methChoice.removeAllItems();
     methChoice.addItem("");
     for (int i = 0; i < methArr.length; i++)
      methChoice.addItem(methArr[i]);
    }
    //win.pack();
   }
  }
 }
});

代码示例来源:origin: org.biojava.thirdparty/forester

private void addClickToOption( final int which, final String title ) {
  _click_to_combobox.addItem( title );
  _click_to_names.add( title );
  _all_click_to_names.put( new Integer( which ), title );
  if ( !_configuration.isUseNativeUI() ) {
    _click_to_combobox.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
    _click_to_combobox.setForeground( getConfiguration().getGuiButtonTextColor() );
  }
}

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

@Override
public void installUI (JComponent c) {
  super.installUI (c);
  JComboBox<?> comboBox = (JComboBox<?>) c;
  comboBox.setFont (UIManager.getFont ("ComboBox.font"));
  comboBox.setBackground (UIManager.getColor ("ComboBox.background"));
  comboBox.setForeground (UIManager.getColor ("ComboBox.foreground"));
  comboBox.setBorder (UIManager.getBorder ("ComboBox.border"));
  comboBox.setLightWeightPopupEnabled (true);
  comboBox.setRenderer (new MaterialComboBoxRenderer ());
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-bugtracking

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(((JTextField) command.getEditor().getEditorComponent()).getDisabledTextColor())) {
    return;
  }
  command.setForeground(areNoResults ? Color.RED : origForeground);
}

代码示例来源:origin: abc9070410/JComicDownloader

private JComboBox getComboBox( String[] strings, int selectedIndex )
  {
    JComboBox comboBox = new JComboBox( strings );
    if ( SetUp.getUsingBackgroundPicOfOptionFrame() )
    { // 若設定為透明,就用預定字體。
      comboBox.setForeground( SetUp.getOptionFrameOtherDefaultColor() );
      comboBox.setOpaque( false );
      comboBox.addMouseListener( this );
    }

    ListCellRenderer renderer = new ComplexCellRenderer();
    comboBox.setRenderer( renderer );
    comboBox.setSelectedIndex( selectedIndex );
    comboBox.setFont( SetUp.getDefaultFont() );

    return comboBox;
  }
}

代码示例来源:origin: org.openbase.bco/dal.visual

unitConfigComboBox.setForeground(Color.BLACK);
  unitConfigObservable.notifyObservers(selectedUnitConfig);
  scopeTextField.setText(ScopeGenerator.generateStringRep(selectedUnitConfig.getScope()));
} catch (MultiException ex) {
  unitConfigComboBox.setForeground(Color.RED);
  statusPanel.setError(ExceptionPrinter.printHistoryAndReturnThrowable(ex, logger));

代码示例来源:origin: org.biojava.thirdparty/forester

public JComboBox<String> getSequenceRelationBox() {
  if ( _show_sequence_relations == null ) {
    _show_sequence_relations = new JComboBox<String>();
    _show_sequence_relations.setFocusable( false );
    _show_sequence_relations.setMaximumRowCount( 20 );
    _show_sequence_relations.setFont( ControlPanel.js_font );
    if ( !_configuration.isUseNativeUI() ) {
      _show_sequence_relations.setBackground( getConfiguration().getGuiButtonBackgroundColor() );
      _show_sequence_relations.setForeground( getConfiguration().getGuiButtonTextColor() );
    }
    _show_sequence_relations.addItem( "-----" );
    _show_sequence_relations.setToolTipText( "To display orthology information for selected query" );
  }
  return _show_sequence_relations;
}

代码示例来源:origin: org.cytoscape/filter2-impl

void handleColumnSelected(View view, JComboBox nameComboBox) {
  RangeChooser rangeChooser = view.rangeChooser;
  if (nameComboBox.getSelectedIndex() == 0) {
    view.handleNoColumnSelected();
    chooserController.setInteractive(false, rangeChooser);
    return;
  }
  nameComboBox.setForeground(Color.black);
  
  ColumnComboBoxElement selected = (ColumnComboBoxElement) nameComboBox.getSelectedItem();
  setColumnName(selected.name);
  setMatchType(selected.columnType);
  
  if (modelMonitor.isString(selected.name, selected.columnType)) {
    Predicate predicate = filter.getPredicate();
    if (predicate == null || predicate == Predicate.BETWEEN) {
      filter.setPredicate(Predicate.CONTAINS);
    }
    
    view.handleStringColumnSelected();
    chooserController.setInteractive(false, rangeChooser);
  } else {
    filter.setPredicate(Predicate.BETWEEN);
    view.handleNumericColumnSelected();
    chooserController.setInteractive(view.isInteractive, rangeChooser);
    updateRange();
  }
}

相关文章

JComboBox类方法