当前位置: 首页>>代码示例>>Java>>正文


Java JComboBox.setFont方法代码示例

本文整理汇总了Java中javax.swing.JComboBox.setFont方法的典型用法代码示例。如果您正苦于以下问题:Java JComboBox.setFont方法的具体用法?Java JComboBox.setFont怎么用?Java JComboBox.setFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JComboBox的用法示例。


在下文中一共展示了JComboBox.setFont方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createComboBox

import javax.swing.JComboBox; //导入方法依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:FixDuplicateImportStmts.java

示例2: SourceControl

import javax.swing.JComboBox; //导入方法依赖的package包/类
/** 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);
            
            
        }
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:41,代码来源:MultiInputPanel.java

示例3: EnumControl

import javax.swing.JComboBox; //导入方法依赖的package包/类
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();
                    }
                }
            });
        }
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:37,代码来源:ParameterControlPanel.java

示例4: stylizeComboBox_disabled

import javax.swing.JComboBox; //导入方法依赖的package包/类
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);
}
 
开发者ID:kevingilboy,项目名称:COE1186,代码行数:8,代码来源:SimulatorGui.java

示例5: stylizeComboBox

import javax.swing.JComboBox; //导入方法依赖的package包/类
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);
}
 
开发者ID:kevingilboy,项目名称:COE1186,代码行数:8,代码来源:SimulatorGui.java

示例6: stylizeComboBox

import javax.swing.JComboBox; //导入方法依赖的package包/类
public void stylizeComboBox(JComboBox c){
	c.setFont(font_14_bold);
	((JLabel)c.getRenderer()).setHorizontalAlignment(JLabel.CENTER);
	c.setForeground(Color.BLACK);
	c.setBackground(Color.WHITE);
}
 
开发者ID:kevingilboy,项目名称:COE1186,代码行数:7,代码来源:CtcGui.java

示例7: fillPanel

import javax.swing.JComboBox; //导入方法依赖的package包/类
@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();
		}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:75,代码来源:SchedulableWrapperMap.java

示例8: createCustomControls

import javax.swing.JComboBox; //导入方法依赖的package包/类
@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;
	}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:56,代码来源:SpikeSoundSignalHandler.java


注:本文中的javax.swing.JComboBox.setFont方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。