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


Java JComboBox类代码示例

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


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

示例1: setup

import javax.swing.JComboBox; //导入依赖的package包/类
private static void setup(final Point tmp) {
    comboBox = new JComboBox<>();
    for (int i = 1; i < 7; i++) {
        comboBox.addItem("Long-long-long-long-long text in the item-" + i);
    }
    String property = System.getProperty(PROPERTY_NAME);
    comboBox.putClientProperty(PROPERTY_NAME, Boolean.valueOf(property));
    frame = new JFrame();
    frame.setAlwaysOnTop(true);
    frame.setLayout(new FlowLayout());
    frame.add(comboBox);
    frame.pack();
    frame.setSize(frame.getWidth(), SIZE);
    frame.setVisible(true);
    frame.setLocation(tmp.x, tmp.y);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:JComboBoxPopupLocation.java

示例2: KMeanScatterPanelChoose

import javax.swing.JComboBox; //导入依赖的package包/类
public KMeanScatterPanelChoose(WorkloadAnalysisSession m) {
	super(new BorderLayout());
	setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Scatter Clustering"));

	model = (ModelWorkloadAnalysis) m.getDataModel();
	this.session = m;

	varXCombo = new JComboBox(model.getMatrix().getVariableNames());
	varYCombo = new JComboBox(model.getMatrix().getVariableNames());
	varXCombo.setSelectedIndex(0);
	varYCombo.setSelectedIndex(1);

	JButton vis = new JButton(VIS_SCATTER);

	JPanel combos = new JPanel(new GridLayout(1, 2, 5, 0));
	combos.add(varXCombo);
	combos.add(varYCombo);

	add(combos, BorderLayout.NORTH);
	add(vis, BorderLayout.SOUTH);
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:22,代码来源:KMeanScatterPanelChoose.java

示例3: getSFSPath

import javax.swing.JComboBox; //导入依赖的package包/类
/**
 * Returns path relative to the root of the SFS. May return
 * <code>null</code> for empty String or user's custom non-string items.
 * Also see {@link Util#isValidSFSPath(String)}.
 */
public static String getSFSPath(final JComboBox lpCombo, final String supposedRoot) {
    Object editorItem = lpCombo.getEditor().getItem();
    String path = null;
    if (editorItem instanceof LayerItemPresenter) {
        path = ((LayerItemPresenter) editorItem).getFullPath();
    } else if (editorItem instanceof String) {
        String editorItemS = ((String) editorItem).trim();
        if (editorItemS.length() > 0) {
            path = searchLIPCategoryCombo(lpCombo, editorItemS);
            if (path == null) {
                // entered by user - absolute and relative are supported...
                path = editorItemS.startsWith(supposedRoot) ? editorItemS :
                    supposedRoot + '/' + editorItemS;
            }
        }
    }
    return path;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:WizardUtils.java

示例4: AnonActionProfileListener

import javax.swing.JComboBox; //导入依赖的package包/类
public AnonActionProfileListener(JComboBox<Object> anonProfiles, JLabel profileLabel, JRadioButton radioBodyCharac1, 
		JRadioButton radioBodyCharac2, JRadioButton radioDates1, JRadioButton radioDates2, JRadioButton radioBd2, 
		JRadioButton radioBd1, JRadioButton radioPt1, JRadioButton radioPt2,
		JRadioButton radioSc1, JRadioButton radioSc2, JRadioButton radioDesc1, JRadioButton radioDesc2){
	this.profileLabel = profileLabel;
	this.anonProfiles = anonProfiles;
	this.radioBodyCharac1 = radioBodyCharac1;
	this.radioBodyCharac2 = radioBodyCharac2;
	this.radioDates1 = radioDates1;
	this.radioDates2 = radioDates2;
	this.radioBd2 = radioBd2;
	this.radioBd1 = radioBd1;
	this.radioPt1 = radioPt1;
	this.radioPt2 = radioPt2;
	this.radioSc1 = radioSc1;
	this.radioSc2 = radioSc2;
	this.radioDesc1 = radioDesc1;
	this.radioDesc2 = radioDesc2;
}
 
开发者ID:anousv,项目名称:OrthancAnonymization,代码行数:20,代码来源:AnonActionProfileListener.java

示例5: setUpSportColumn

import javax.swing.JComboBox; //导入依赖的package包/类
public void setUpSportColumn(JTable table, TableColumn sportColumn) {
    // Set up the editor for the sport cells.
    JComboBox comboBox = new JComboBox();
    comboBox.addItem("Snowboarding");
    comboBox.addItem("Rowing");
    comboBox.addItem("Knitting");
    comboBox.addItem("Speed reading");
    comboBox.addItem("Pool");
    comboBox.addItem("None of the above");
    sportColumn.setCellEditor(new DefaultCellEditor(comboBox));

    // Set up tool tips for the sport cells.
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for combo box");
    sportColumn.setCellRenderer(renderer);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:17,代码来源:TableRenderDemo.java

示例6: createPositionModel

import javax.swing.JComboBox; //导入依赖的package包/类
private void createPositionModel(final JComboBox positionsCombo,
        final FileObject[] files,
        final LayerItemPresenter parent) {
    DefaultComboBoxModel newModel = new DefaultComboBoxModel();
    LayerItemPresenter previous = null;
    for (FileObject file : files) {
        if (file.getNameExt().endsWith(LayerUtil.HIDDEN)) {
            continue;
        }
        LayerItemPresenter current = new LayerItemPresenter(
                file,
                parent.getFileObject());
        newModel.addElement(createPosition(previous, current));
        previous = current;
    }
    newModel.addElement(createPosition(previous, null));
    positionsCombo.setModel(newModel);
    checkValidity();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:GUIRegistrationPanel.java

示例7: testMatchTypeComboBoxWithUnsupportedTypes

import javax.swing.JComboBox; //导入依赖的package包/类
@Test
public void testMatchTypeComboBoxWithUnsupportedTypes() {
    JComboBox cb = new JComboBox();
    SearchPatternController controller =
            ComponentUtils.adjustComboForSearchPattern(cb);
    JComboBox matchTypeCb = new JComboBox(
            new Object[]{MatchType.LITERAL, MatchType.REGEXP});
    controller.bindMatchTypeComboBox(matchTypeCb);
    assertEquals(MatchType.LITERAL, matchTypeCb.getSelectedItem());
    controller.setSearchPattern(SearchPattern.create("test", false, false,
            MatchType.BASIC));
    assertEquals(MatchType.LITERAL,
            controller.getSearchPattern().getMatchType());
    controller.setSearchPattern(SearchPattern.create("test", false, false,
            MatchType.REGEXP));
    assertEquals(MatchType.REGEXP,
            controller.getSearchPattern().getMatchType());
    controller.setSearchPattern(SearchPattern.create("test", false, false,
            MatchType.BASIC));
    assertEquals(MatchType.REGEXP,
            controller.getSearchPattern().getMatchType());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:SearchPatternControllerTest.java

示例8: assertContentDuplicates

import javax.swing.JComboBox; //导入依赖的package包/类
public void assertContentDuplicates() throws InterruptedException {
    siw(new Runnable() {
        @Override public void run() {
            combo = (JComboBox) ComponentUtils.findComponent(JComboBox.class, frame);
        }
    });
    final RComboBox rCombo = new RComboBox(combo, null, null, new LoggingRecorder());
    final Object[] content = new Object[] { null };
    siw(new Runnable() {
        @Override public void run() {
            content[0] = rCombo.getContent();
        }
    });
    JSONArray a = new JSONArray(content[0]);
    AssertJUnit.assertEquals("[[\"Phillip\",\"Larry\",\"Lisa\",\"James\",\"Larry(1)\"]]", a.toString());
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:17,代码来源:RComboBox2Test.java

示例9: initializeComboBoxes

import javax.swing.JComboBox; //导入依赖的package包/类
private void initializeComboBoxes() throws Exception {

		List<LocalidadeVO> localidades = this.cadastroRota.recuperarLocalidades();

		this.cboxOrigem = new JComboBox<LocalidadeVO>();
		this.startComboBoxValues(this.cboxOrigem, localidades);

		GridBagConstraints gbc_comboBox = new GridBagConstraints();
		gbc_comboBox.insets = new Insets(0, 0, 5, 5);
		gbc_comboBox.fill = GridBagConstraints.HORIZONTAL;
		gbc_comboBox.gridx = 3;
		gbc_comboBox.gridy = 3;
		this.panel.add(this.cboxOrigem, gbc_comboBox);

		this.cboxDestino = new JComboBox<LocalidadeVO>();
		this.startComboBoxValues(this.cboxDestino, localidades);

		GridBagConstraints gbc_comboBox_1 = new GridBagConstraints();
		gbc_comboBox_1.insets = new Insets(0, 0, 5, 5);
		gbc_comboBox_1.fill = GridBagConstraints.HORIZONTAL;
		gbc_comboBox_1.gridx = 3;
		gbc_comboBox_1.gridy = 8;
		this.panel.add(this.cboxDestino, gbc_comboBox_1);
	}
 
开发者ID:cjlcarvalho,项目名称:LogisticApp,代码行数:25,代码来源:DiretaPanelBuilder.java

示例10: setRepository

import javax.swing.JComboBox; //导入依赖的package包/类
private void setRepository(Repository repository, HookPanel panel) throws IllegalArgumentException, IllegalAccessException {
    Field[] fs = panel.qs.getClass().getDeclaredFields();
    for (Field f : fs) {
        if(f.getType() == QuickSearchPanel.class) {
            f.setAccessible(true);
            QuickSearchPanel qsp = (QuickSearchPanel) f.get(panel.qs);
            fs = qsp.getClass().getDeclaredFields();
            for (Field f2 : fs) {
                if(f2.getType() == JComboBox.class) {
                    f2.setAccessible(true);
                    JComboBox cmb = (JComboBox) f2.get(qsp);
                    DefaultComboBoxModel model = new DefaultComboBoxModel(new Repository[] {repository});
                    cmb.setModel(model);
                    cmb.setSelectedItem(repository);
                    return;
                }
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:HgHookTest.java

示例11: isMemorySelectionError

import javax.swing.JComboBox; //导入依赖的package包/类
/**
 * Checks if is memory selection error. The initial memory should 
 * always be larger than the maximum memory of the JVM.
 * @return true, if is memory selection error
 */
private boolean isMemorySelectionError(JComboBox<String> combo) {
	
	boolean error = false;
	String initialMemory = (String) getJComboBoxJVMMemoryInitial().getSelectedItem();
	String maximumMemory = (String) getJComboBoxJVMMemoryMaximum().getSelectedItem();
	int initMem = Integer.parseInt(initialMemory.replaceAll("[a-zA-Z]", ""));
	int maxiMem = Integer.parseInt(maximumMemory.replaceAll("[a-zA-Z]", ""));
	if(initialMemory.contains("g")){
		initMem = initMem*1024;
	}
	if(maximumMemory.contains("g")){
		maxiMem = maxiMem*1024;
	}
	
	if (initMem>=maxiMem) {
		combo.hidePopup();
		String head = Language.translate("Initialer Arbeitsspeicher >= Maximaler Arbeitsspeicher !");
		String msg = Language.translate("Der maximale Arbeitsspeicher muss größer als der initiale Arbeitsspeicher sein.");
		JOptionPane.showMessageDialog(Application.getMainWindow(), msg, head, JOptionPane.ERROR_MESSAGE);
		error = true;
	}
	return error;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:29,代码来源:Distribution.java

示例12: confirm

import javax.swing.JComboBox; //导入依赖的package包/类
private void confirm(EventObject fe) {
    JTextField tf = (JTextField) fe.getSource();
    JComboBox combo = (JComboBox) tf.getParent();
    if (combo==null)
        return;
    if (fe instanceof FocusEvent) {
        combo.getEditor().getEditorComponent().removeFocusListener(this);
    } else {
        combo.getEditor().getEditorComponent().removeKeyListener(this);
    }
    Configuration config = configName==null ? 
            ConfigurationsManager.getDefault().duplicate(lastSelected, tf.getText(), tf.getText()):
            ConfigurationsManager.getDefault().create(tf.getText(), tf.getText());
    combo.setSelectedItem(config);
    combo.setEditable(false);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ConfigurationsComboModel.java

示例13: isElementEditable

import javax.swing.JComboBox; //导入依赖的package包/类
/**
 * Check if the element is editable or not
 *
 * @return if the element is editable or not
 */
@PublicAtsApi
public boolean isElementEditable() {

    try {

        Component component = SwingElementLocator.findFixture(element).component();
        if (component instanceof JTextComponent) {
            return ((JTextComponent) component).isEditable();
        } else if (component instanceof JComboBox) {
            return ((JComboBox) component).isEditable();
        } else if (component instanceof JTree) {
            return ((JTree) component).isEditable();
        }
        throw new NotSupportedOperationException("Component of type \"" + component.getClass().getName()
                                                 + "\" doesn't have 'editable' state!");
    } catch (ElementNotFoundException nsee) {
        lastNotFoundException = nsee;
        return false;
    }
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:26,代码来源:SwingElementState.java

示例14: FontInterpolator

import javax.swing.JComboBox; //导入依赖的package包/类
public FontInterpolator(Font selectedFont, GetSet gs, ChangeListener... listeners) {
	super(gs, listeners);
	
	Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
	String[] fontNames = new String[fonts.length];
	for(int i = 0; i < fonts.length; i++)
		fontNames[i] = fonts[i].getFontName();
	
	box = new JComboBox<String>(fontNames) {

		private static final long serialVersionUID = 2454221612986775298L;

		@Override 
		public Dimension getPreferredSize() {
			Dimension ps = super.getPreferredSize();
			return new Dimension(Math.min(ps.width, 120), ps.height);
		}
	};
	
	box.setSelectedItem(selectedFont.getFontName());
	box.addActionListener(ae -> {
		fireChangeEvent();
	});
}
 
开发者ID:CalebKussmaul,项目名称:GIFKR,代码行数:25,代码来源:FontInterpolator.java

示例15: actionPerformed

import javax.swing.JComboBox; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent ae) {
    if (ConfigurationsManager.getDefault().size() == 1) {
        setSelectedItem(getElementAt(0));
        return;
    }
    JComboBox combo = (JComboBox) ae.getSource();
    combo.setSelectedItem(lastSelected);
    combo.hidePopup();
    if (JOptionPane.showConfirmDialog(combo, 
    Bundle.MSG_ReallyDeleteConfig(lastSelected),
    Bundle.DeleteConfigTitle(),
    JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
        ConfigurationsManager.getDefault().remove(lastSelected);
        setSelectedItem(getElementAt(0));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ConfigurationsComboModel.java


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