Java Code Examples for javax.swing.JComboBox#setForeground()

The following examples show how to use javax.swing.JComboBox#setForeground() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExpressionPane.java    From snap-desktop with GNU General Public License v3.0 8 votes vote down vote up
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;
}
 
Example 2
Source File: ControlsDialog.java    From WorldGrower with GNU General Public License v3.0 6 votes vote down vote up
private void addPerformancePanel(KeyBindings keyBindings) {
	JPanel performancePanel = JPanelFactory.createJPanel("Performance");
	performancePanel.setOpaque(false);
	performancePanel.setBounds(15, 310, 368, 100);
	performancePanel.setLayout(null);
	
	JLabel lblAnimationSpeed = JLabelFactory.createJLabel("Animation Speed:");
	lblAnimationSpeed.setToolTipText(ANIMATION_SPEED_TOOL_TIP);
	lblAnimationSpeed.setOpaque(false);
	lblAnimationSpeed.setBounds(12, 25, 137, 25);
	performancePanel.add(lblAnimationSpeed);

	JComboBox<AnimationSpeed> cmbAnimationSpeed = JComboBoxFactory.createJComboBox(AnimationSpeed.values(), imageInfoReader);
	cmbAnimationSpeed.setForeground(Color.BLACK);
	cmbAnimationSpeed.setToolTipText(ANIMATION_SPEED_TOOL_TIP);
	cmbAnimationSpeed.setSelectedItem(keyBindings.getAnimationSpeed());
	cmbAnimationSpeed.setOpaque(false);
	cmbAnimationSpeed.setBounds(228, 25, 127, 25);
	performancePanel.add(cmbAnimationSpeed);
	
	cmbAnimationSpeed.addActionListener(e -> keyBindings.setAnimationSpeed((AnimationSpeed)cmbAnimationSpeed.getSelectedItem()));
	
	addComponent(performancePanel);
}
 
Example 3
Source File: JComboBoxFactory.java    From WorldGrower with GNU General Public License v3.0 5 votes vote down vote up
private static<T> void setComboBoxProperties(JComboBox<T> comboBox, ImageInfoReader imageInfoReader) {
	comboBox.setOpaque(false);
	comboBox.setBackground(ColorPalette.FOREGROUND_COLOR);
	comboBox.setForeground(ColorPalette.FOREGROUND_COLOR);
	comboBox.setFont(Fonts.FONT);
	
	comboBox.setUI(new MetalComboBoxUI() {

		@Override
		protected ComboPopup createPopup() {
			return new TiledImageComboPopup( comboBox, imageInfoReader );
		}
	});
}
 
Example 4
Source File: UIRes.java    From RipplePower with Apache License 2.0 5 votes vote down vote up
public static void addStyle(JComboBox<Object> textField, String labelName) {
	Border line = BorderFactory.createLineBorder(Color.LIGHT_GRAY);
	TitledBorder titled = BorderFactory.createTitledBorder(line, labelName);
	titled.setTitleFont(GraphicsUtils.getFont("Verdana", 0, 13));
	titled.setTitleColor(fontColorTitle);
	Border empty = new EmptyBorder(0, 8, 0, 8);
	CompoundBorder border = new CompoundBorder(titled, empty);
	textField.setBorder(border);
	textField.setForeground(fontColor);
	textField.setFont(GraphicsUtils.getFont("Monospaced", 0, 13));
}
 
Example 5
Source File: ScrLexicon.java    From PolyGlot with MIT License 5 votes vote down vote up
/**
 * Sets appropriate fields grey
 */
private void setGreyFields(JComponent comp, String defValue) {
    if (comp instanceof JComboBox) {
        JComboBox compCmb = (JComboBox) comp;
        if (compCmb.getSelectedItem() != null
                && compCmb.getSelectedItem().toString().equals(defValue)) {
            compCmb.setForeground(Color.red);
        } else {
            compCmb.setForeground(Color.black);
        }
    }
}