Java Code Examples for javax.swing.JComboBox.setFont()

The following are Jave code examples for showing how to use setFont() of the javax.swing.JComboBox class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: jaer   File: MultiInputPanel.java   Source Code and License Vote up 6 votes
/** Add a source controller that changes the packet source streams upon selection */
        public SourceControl(final ArrayList<PacketStream> sources, final ProcessingNetwork.Node f, final String name, final int sourceIndex) {
            super();
            filter = f;
            setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
            setAlignmentX(LEFT_ALIGNMENT);
            final JLabel label = new JLabel(name);
            label.setAlignmentX(LEFT_ALIGNMENT);
            label.setFont(label.getFont().deriveFont(fontSize));
//            addTip(f, label);
                        
            add(label);

            String[] names=new String[sources.size()];
            for (int i=0; i<sources.size();i++)
                names[i]=sources.get(i).getName();
                        
            control = new JComboBox(names);
            control.setFont(control.getFont().deriveFont(fontSize));
//            control.setHorizontalAlignment(SwingConstants.LEADING);
            
            control.addActionListener(new ActionListener(){

                @Override
                public void actionPerformed(ActionEvent e) {
                    try {
                        node.setSource(sourceIndex, sources.get(control.getSelectedIndex()));
                    } catch (Exception ex) {
                        node.setEnabled(false);
                        Logger.getLogger(MultiInputPanel.class.getName()).log(Level.SEVERE, "Source index higher than number of sources", ex);
                    }
                }
            });
            
            
            add(label);
            add(control);
            
            
        }
 
Example 2
Project: incubator-netbeans   File: FixDuplicateImportStmts.java   Source Code and License Vote up 5 votes
private JComboBox createComboBox(CandidateDescription[] choices, CandidateDescription defaultValue, Font font, FocusListener listener ) {
    JComboBox combo = new JComboBox(choices);
    combo.setSelectedItem(defaultValue);
    combo.getAccessibleContext().setAccessibleDescription(getBundleString("FixDupImportStmts_Combo_ACSD")); //NOI18N
    combo.getAccessibleContext().setAccessibleName(getBundleString("FixDupImportStmts_Combo_Name_ACSD")); //NOI18N
    combo.setOpaque(false);
    combo.setFont( font );
    combo.addFocusListener( listener );
    combo.setEnabled( choices.length > 1 );
    combo.setRenderer( new DelegatingRenderer(combo.getRenderer()));
    InputMap inputMap = combo.getInputMap( JComboBox.WHEN_FOCUSED );
    inputMap.put( KeyStroke.getKeyStroke( KeyEvent.VK_SPACE, 0), "showPopup" ); //NOI18N
    combo.getActionMap().put( "showPopup", new TogglePopupAction() ); //NOI18N
    return combo;
}
 
Example 3
Project: jaer   File: ParameterControlPanel.java   Source Code and License Vote up 5 votes
public EnumControl(final Class<? extends Enum> c, final Object f, PropertyDescriptor p) {
            super();
            final String name = p.getName();
            final Method r = p.getReadMethod(), w = p.getWriteMethod();

            setterMap.put(name, this);
            clazz = f;
            write = w;
            read = r;
            setLayout(new GridLayout(1, 0));
//            setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
            setAlignmentX(ALIGNMENT);
            final JLabel label = new JLabel(name);
            label.setAlignmentX(ALIGNMENT);
            label.setFont(label.getFont().deriveFont(fontSize));
            addTip(p, label);
            add(label);

            control = new JComboBox(c.getEnumConstants());
            control.setFont(control.getFont().deriveFont(fontSize));
//            control.setHorizontalAlignment(SwingConstants.LEADING);

            add(label);
            add(control);
            refresh();
            control.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    try {
                        w.invoke(clazz, control.getSelectedItem());
                    } catch (Exception e2) {
                        e2.printStackTrace();
                    }
                }
            });
        }
 
Example 4
Project: COE1186   File: SimulatorGui.java   Source Code and License Vote up 5 votes
public void stylizeComboBox_disabled(JComboBox c){
	c.setFont(font_14_bold);
	((JLabel)c.getRenderer()).setHorizontalAlignment(JLabel.CENTER);
	c.setForeground(Color.BLACK);
	c.setBackground(new Color(26, 29, 35));
	c.setEnabled(false);
}
 
Example 5
Project: COE1186   File: SimulatorGui.java   Source Code and License Vote up 5 votes
public void stylizeComboBox(JComboBox c){
	c.setFont(font_14_bold);
	((JLabel)c.getRenderer()).setHorizontalAlignment(JLabel.CENTER);
	c.setForeground(Color.BLACK);
	c.setBackground(Color.WHITE);
	c.setEnabled(true);
}
 
Example 6
Project: COE1186   File: CtcGui.java   Source Code and License Vote up 5 votes
public void stylizeComboBox(JComboBox c){
	c.setFont(font_14_bold);
	((JLabel)c.getRenderer()).setHorizontalAlignment(JLabel.CENTER);
	c.setForeground(Color.BLACK);
	c.setBackground(Color.WHITE);
}
 
Example 7
Project: COE1186   File: MboGui.java   Source Code and License Vote up 5 votes
public void stylizeComboBox(JComboBox c){
	c.setFont(font_14_bold);
	((JLabel)c.getRenderer()).setHorizontalAlignment(JLabel.CENTER);
	c.setForeground(Color.BLACK);
	c.setBackground(Color.WHITE);
}
 
Example 8
Project: jaer   File: SchedulableWrapperMap.java   Source Code and License Vote up 4 votes
@Override
		protected void fillPanel() {
			JPanel creatorPanel = new JPanel();
            creatorPanel.setLayout(new BoxLayout(creatorPanel, BoxLayout.X_AXIS));
            creatorPanel.setAlignmentX(ParameterBrowserPanel.ALIGNMENT);
            JLabel label = new JLabel("Unit-Type:");
            label.setFont(label.getFont().deriveFont(10f));
			creatorPanel.add(label);


			@SuppressWarnings({ "unchecked", "rawtypes" })
			final JComboBox creatorComboBox = new JComboBox(creatorList.toArray());
			getSupport().addPropertyChangeListener("firingModelCreator", new PropertyChangeListener() {
				@Override
				public void propertyChange(PropertyChangeEvent evt) {
					int index = 0;
					int i = 0;
					for (Object o : creatorList) {
						if (o.toString().equals(evt.getNewValue().toString())) {
							index = i;
						}
						i++;
					}
					if (index != creatorComboBox.getSelectedIndex()) {
						creatorComboBox.setSelectedIndex(index);
					}
				}
			});

			creatorComboBox.setFont(creatorComboBox.getFont().deriveFont(10f));
			creatorPanel.add(creatorComboBox);
			creatorComboBox.setSelectedIndex(getCreatorIndex());
			creatorComboBox.addActionListener(new ActionListener() {
				@Override
				public void actionPerformed(ActionEvent arg0) {
					setFiringModelCreator(creatorComboBox.getSelectedItem());
//					if (creatorComboBox.getSelectedIndex() == 0) {
//						setFiringModelCreator((FiringModelCreator)null);
//						setFiringModelCreator((SchedulableFiringModelCreator)null);
//					}
//					else if (creatorComboBox.getSelectedIndex() <= firingModelCreatorCounter) {
//						SchedulableWrapperMap.this.setFiringModelCreator(FiringModelCreator
//								.getCreator(
//										(FiringModelCreator.FiringModelType) creatorComboBox
//												.getSelectedItem(), getPrefs()
//												.node("creator")));
//					}
//					else {
//						SchedulableWrapperMap.this.setFiringModelCreator(SchedulableFiringModelCreator
//								.getCreator(
//										(SchedulableFiringModelCreator.FiringModelType) creatorComboBox
//												.getSelectedItem(), getPrefs()
//												.node("creator")));
//					}
//					getSupport().fire
					creatorChanged();
				}
			});

			add(creatorPanel,gbc);
			gbc.gridy++;

			creatorConstraints = new GridBagConstraints();
			creatorConstraints.weightx = gbc.weightx;
			creatorConstraints.weighty = gbc.weighty;
			creatorConstraints.gridx = gbc.gridx;
			creatorConstraints.gridy = gbc.gridy;
			creatorConstraints.fill = gbc.fill;
			gbc.gridy++;

			creatorChanged();

			super.fillPanel();
		}
 
Example 9
Project: jaer   File: SpikeSoundSignalHandler.java   Source Code and License Vote up 4 votes
@SuppressWarnings("rawtypes")
	protected JComponent createCustomControls() {
		myComboBox = new JComboBox();
		myComboBox.setFont(myComboBox.getFont().deriveFont(10f));
		
		ArrayList<FiringModelMap> contents;
		if (stf != null) {
			stf.getSupport().addPropertyChangeListener("firingModelMaps", this);
			contents = stf.getFiringModelMaps();
		}
		else 
			contents = new ArrayList<FiringModelMap>();
		updateComboBox(new ArrayList<FiringModelMap>(), contents);
		
		myComboBox.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {
				Object newSelection = myComboBox.getSelectedItem();
				if (newSelection != currentSelection) {
					if (stf != null) {
						synchronized (stf.getFilteringLock()) {
							currentSelection = newSelection;
							if (currentSelection instanceof FiringModelMap)
								setInputMap((FiringModelMap)currentSelection);
							else 
								setInputMap(null);
						}

					}

				}
			}
		});
		
		
		getSupport().addPropertyChangeListener("inputMap",new PropertyChangeListener() {
			@Override
			public void propertyChange(PropertyChangeEvent evt) {
				if (evt.getNewValue() != evt.getOldValue()) {
					if (evt.getNewValue() != null)
						myComboBox.setSelectedItem(evt.getNewValue());
					else
						myComboBox.setSelectedIndex(0);
				}
}
		});
		JPanel customPanel = new JPanel();
        customPanel.setLayout(new BoxLayout(customPanel, BoxLayout.X_AXIS));
        customPanel.setAlignmentX(ParameterBrowserPanel.ALIGNMENT);
        final JLabel jLabel = new JLabel("Input map:");
        jLabel.setFont(jLabel.getFont().deriveFont(10f));
		customPanel.add(jLabel);
        customPanel.add(myComboBox);
        return customPanel;
	}
 
Example 10
Project: COE1186   File: TrackControllerGUI.java   Source Code and License Vote up 4 votes
public void stylizeComboBox(JComboBox c){
	c.setFont(font_14_bold);
	((JLabel)c.getRenderer()).setHorizontalAlignment(JLabel.CENTER);
	c.setForeground(Color.BLACK);
	c.setBackground(Color.WHITE);
}
 
Example 11
Project: COE1186   File: TrainModelGUI.java   Source Code and License Vote up 4 votes
public void stylizeComboBox(JComboBox c){
	c.setFont(font_14_bold);
	((JLabel)c.getRenderer()).setHorizontalAlignment(JLabel.CENTER);
	c.setForeground(Color.BLACK);
	c.setBackground(Color.WHITE);
}
 
Example 12
Project: COE1186   File: TrainControllerGUI.java   Source Code and License Vote up 4 votes
public void stylizeComboBox(JComboBox c){
	c.setFont(font_14_bold);
	((JLabel)c.getRenderer()).setHorizontalAlignment(JLabel.CENTER);
	c.setForeground(Color.BLACK);
	c.setBackground(Color.WHITE);
}
 
Example 13
Project: COE1186   File: TrnControllerGUI.java   Source Code and License Vote up 4 votes
public void stylizeComboBox(JComboBox c){
	c.setFont(font_14_bold);
	((JLabel)c.getRenderer()).setHorizontalAlignment(JLabel.CENTER);
	c.setForeground(Color.BLACK);
	c.setBackground(Color.WHITE);
}
 
Example 14
Project: COE1186   File: TrackModelGUI.java   Source Code and License Vote up 4 votes
public void stylizeComboBox(JComboBox c){
	c.setFont(font_14_bold);
	((JLabel)c.getRenderer()).setHorizontalAlignment(JLabel.CENTER);
	c.setForeground(Color.BLACK);
	c.setBackground(Color.WHITE);
}