當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。