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


Java JComboBox.setModel方法代码示例

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


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

示例1: getTableCellEditorComponent

import javax.swing.JComboBox; //导入方法依赖的package包/类
public Component getTableCellEditorComponent(JTable table, Object obj, boolean isSelected, int row, int col) {  
                      comboBox = new JComboBox();   
                      comboBox.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent event) {
                                  fireEditingStopped();
		}
	});
                      DefaultComboBoxModel rootModel = new DefaultComboBoxModel();
                      SchemaObject o = (SchemaObject)table.getModel().getValueAt(row, SCHEMA_COL);
                      
                      if( !(o.toString().equals(startString))) {
                          String[] root = o.getRootElements();
                          if(root != null && root.length >0) {
                              for(int i=0; i < root.length; i++)
                                  rootModel.addElement(root[i]);
                          }
                      }                           
                      comboBox.setModel(rootModel);
	return comboBox;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:SchemaPanel.java

示例2: InputDataPanel

import javax.swing.JComboBox; //导入方法依赖的package包/类
public InputDataPanel(List<String> previouslyUsedURLs) {
	setSize(new Dimension(900, 300));
	setPreferredSize(new Dimension(900, 300));
	setMinimumSize(new Dimension(450, 300));
	setLayout(null);

	JLabel lblInputDataUrl = new JLabel("Input data URL");
	lblInputDataUrl.setBounds(12, 12, 105, 15);
	add(lblInputDataUrl);

	lblUrlIsInvalid = new JLabel("URL is invalid!");
	lblUrlIsInvalid.setVisible(false);
	lblUrlIsInvalid.setBounds(12, 70, 105, 15);
	add(lblUrlIsInvalid);

	btnValidate = new JButton("Validate");
	btnValidate.setBounds(335, 34, 93, 25);
	//add(btnValidate);

	comboBox = new JComboBox();
	comboBox.setEditable(true);
	comboBox.setBounds(12, 34, 311, 24);
	comboBox.setModel(new URLComboBoxModel(previouslyUsedURLs));
	add(comboBox);
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:26,代码来源:InputDataPanel.java

示例3: 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,代码来源:SvnHookTest.java

示例4: updateIndexList

import javax.swing.JComboBox; //导入方法依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
protected void updateIndexList(ClassData.Class basis)
{
    JComboBox<?> indexes = selects.get("indexcode");
    if (indexes.isVisible())
    {
        Object selected = indexes.getSelectedItem();
        if (override.isSelected() || (basis == null))
        {
            indexes.setModel(new DefaultComboBoxModel(indexlist.toArray()));
        }
        else
        {
            Set<ClassData.Index>[] lists = basis.restrictedIndexes(indexlist);
            ClassData.Index[] allowed = lists[0].toArray(new ClassData.Index[0]);
            Arrays.sort(allowed, new ClassData.Index.StringOrder());
            indexes.setModel(new DefaultComboBoxModel(allowed));
        }

        indexes.setSelectedItem(selected);  // if index is still available, keep it selected
    }
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:23,代码来源:CarDialog.java

示例5: 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

示例6: initCombo

import javax.swing.JComboBox; //导入方法依赖的package包/类
private void initCombo(JComboBox providerCombo) {
    
    DefaultComboBoxModel providers = new DefaultComboBoxModel();
    
    for(Provider each : providerSupplier.getSupportedProviders()){
       providers.addElement(each);
    }

    if (providers.getSize() == 0 && providerSupplier.supportsDefaultProvider()){
        providers.addElement(ProviderUtil.DEFAULT_PROVIDER);
    } 

    if (providers.getSize() == 0){
        providers.addElement(EMPTY);
    }
    
    providerCombo.setModel(providers);
    providerCombo.addItem(SEPARATOR);
    providerCombo.addItem(new NewPersistenceLibraryItem());
    providerCombo.addItem(new ManageLibrariesItem());
    providerCombo.setRenderer(new PersistenceProviderCellRenderer(getDefaultProvider(providers)));
    //select either default or first or preferred provider depending on project details
    int selectIndex = 0;
    if(providers.getSize()>1 && providers.getElementAt(0) instanceof Provider){
        String defProviderVersion = ProviderUtil.getVersion((Provider) providers.getElementAt(0));
        boolean specialCase = (Util.isJPAVersionSupported(project, Persistence.VERSION_2_0) || Util.isJPAVersionSupported(project, Persistence.VERSION_2_1)) && (defProviderVersion == null || defProviderVersion.equals(Persistence.VERSION_1_0));//jpa 2.0 is supported by default (or first) is jpa1.0 or udefined version provider
        if(specialCase){
            for (int i = 1; i<providers.getSize() ; i++){
                if(preferredProvider.equals(providers.getElementAt(i))){
                    selectIndex = i;
                    break;
                }
            }
        }
    }
    providerCombo.setSelectedIndex(selectIndex);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:PersistenceProviderComboboxHelper.java

示例7: AddBreakPoint

import javax.swing.JComboBox; //导入方法依赖的package包/类
/**
 * Create the frame.
 */
public AddBreakPoint(DefaultListModel<BreakPoint> breakpoint) {
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	setBounds(100, 100, 450, 300);
	contentPane = new JPanel();
	contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
	setContentPane(contentPane);
	contentPane.setLayout(null);
	
	JComboBox<Object> comboBox = new JComboBox<Object>();
	comboBox.setModel(new DefaultComboBoxModel<Object>(Variable.values()));
	comboBox.setBounds(10, 115, 141, 20);
	contentPane.add(comboBox);
	
	textField = new JTextField();
	textField.setBounds(226, 115, 141, 20);
	contentPane.add(textField);
	textField.setColumns(10);
	
	JButton btnAddBreakpoint = new JButton("Add BreakPoint");
	btnAddBreakpoint.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent arg0) {
			Object val = null;
			String text = textField.getText().toLowerCase();
			if(text.equals("true"))
				val = true;
			else if(text.equals("false"))
				val = false;
			else{
				val = Integer.parseInt(text, 16);
			}
			breakpoint.addElement(new BreakPoint((Variable) comboBox.getSelectedItem(),val));
			setVisible(false);
			dispose();
		}
	});
	btnAddBreakpoint.setBounds(138, 191, 141, 23);
	contentPane.add(btnAddBreakpoint);
}
 
开发者ID:QuantumSoundings,项目名称:BassNES,代码行数:42,代码来源:AddBreakPoint.java

示例8: initProperties

import javax.swing.JComboBox; //导入方法依赖的package包/类
@Override
protected void initProperties() {
    setTitle("Exclusive Pokémon editor");
    
    // Initialize the components
    
    lblPokemon = new JLabel("Pokémon");
    cmoPokemon = new JComboBox();
    cmoPokemon.setModel(new DefaultComboBoxModel(Lists.pokemon.toArray()));
    chkRed = new JCheckBox("Found in Red Rescue Team");
    chkBlue = new JCheckBox("Found in Blue Rescue Team");
    
    // Add the components to the property panel
    properties.addCaption("Exclusive Pokémon settings");
    properties.addLabeledComponent(lblPokemon, cmoPokemon);
    properties.addComponent(chkRed);
    properties.addComponent(chkBlue);
    properties.addTerminator();
    
    // Create additional toolbar components
    btnClear = new JButton("Clear entries");
    btnClear.addActionListener((java.awt.event.ActionEvent evt) -> {
        for (int i = 0 ; i < RomFile.current.exclusivePokemon.size() ; i++) {
            ExclusivePokemon exc = RomFile.current.exclusivePokemon.get(i);
            exc.species = 0;
            exc.red = false;
            exc.blue = false;
            model.set(i, exc.toString());
        }
    });
    toolbar.add(btnClear);
}
 
开发者ID:SunakazeKun,项目名称:PMDe,代码行数:33,代码来源:ExclusivePokemonEditor.java

示例9: setInheritedColor

import javax.swing.JComboBox; //导入方法依赖的package包/类
static void setInheritedColor (JComboBox<ColorValue> combo, Color color) {
ColorValue[] ncontent = new ColorValue [content.length];
System.arraycopy (content, 0, ncontent, 0, content.length);
       if (color != null)
           ncontent [content.length - 1] = new ColorValue (
               loc ("CTL_Inherited_Color"), color                   //NOI18N
           );
       else
           ncontent [content.length - 1] = new ColorValue (
               loc ("CTL_None_Color"), null                       //NOI18N
           );
combo.setModel (new DefaultComboBoxModel<> (ncontent));
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:ColorComboBox.java

示例10: setEmptyModel

import javax.swing.JComboBox; //导入方法依赖的package包/类
private void setEmptyModel(JComboBox combo) {
    if (combo != null) {
        combo.setModel(WizardUtils.createComboEmptyModel());
        combo.setEnabled(false);
        combo.setEditable(false);
        checkValidity();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:GUIRegistrationPanel.java

示例11: populate

import javax.swing.JComboBox; //导入方法依赖的package包/类
private static List populate(List<String> types, boolean creationSupported, final JComboBox combo, final String selectedType, boolean selectItemLater) {    

        
        List<Object> items = (types == null ? new LinkedList<Object>() : new LinkedList<Object>(types));
        
        if (items.size() > 0) {
            items.add(SEPARATOR_ITEM);
        }   
        
        if (creationSupported) {
            items.add(NEW_ITEM);
        }
        
        
        ReturnTypeComboBoxModel model = new ReturnTypeComboBoxModel(types, items);

        combo.setModel(model);
        
        if (selectedType != null) {

            // Ensure that the correct item is selected before listeners like FocusListener are called.
            // ActionListener.actionPerformed() is not called if this method is already called from 
            // actionPerformed(), in that case selectItemLater should be set to true and setSelectedItem()
            // below is called asynchronously so that the actionPerformed() is called
            setSelectedItem(combo, selectedType); 

            if (selectItemLater) {
                SwingUtilities.invokeLater(new Runnable() { // postpone item selection to enable event firing from JCombobox.setSelectedItem()
                    public void run() {
                        setSelectedItem(combo, selectedType); 
//                        populate(LVALUE_TYPES, true, combo, "Object", false);
                    }
                });
            }

        }
        
        return types;
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:40,代码来源:ReturnTypeUIHelper.java

示例12: createCombo

import javax.swing.JComboBox; //导入方法依赖的package包/类
private JComboBox createCombo(JPanel panel, Enum e) {
    JComboBox cmb = new JComboBox();
    cmb.setModel(new EnumComboBoxModel(e.getClass()));
    cmb.addActionListener(this);
    panel.add(cmb);
    return cmb;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:MultiGradientTest.java

示例13: initProperties

import javax.swing.JComboBox; //导入方法依赖的package包/类
@Override
protected void initProperties() {
    setTitle("Friend area editor");
    
    // Initialize the components
    lblName = new JLabel("Name");
    lblNamePointer = new JLabel("Name pointer");
    lblCount = new JLabel("No. of Pokémon");
    lblCondition = new JLabel("Unlock condition");
    lblPrice = new JLabel("Price");
    txtName = new JTextField("00000000");
    txtName.setEditable(false);
    txtNamePointer = new JTextField();
    txtNamePointer.setEditable(false);
    spnCount = new JSpinner();
    spnCount.setModel(new SpinnerNumberModel(0, 0, 15, 1));
    cmoCondition = new JComboBox();
    cmoCondition.setModel(new DefaultComboBoxModel(new String[] { "0x0: Shop (Story-game)", "0x1: Shop (Post-game)", "0x2: Wonder mail event", "0x3: Legendary request" }));
    spnPrice = new JSpinner();
    spnPrice.setModel(new SpinnerNumberModel(Long.valueOf(0L), Long.valueOf(0L), Long.valueOf(99999L), Long.valueOf(1L)));
    
    // Add the components to the property panel
    properties.addCaption("Area settings");
    properties.addLabeledComponent(lblName, txtName);
    properties.addLabeledComponent(lblNamePointer, txtNamePointer);
    properties.addLabeledComponent(lblCount, spnCount);
    properties.addLabeledComponent(lblCondition, cmoCondition);
    properties.addLabeledComponent(lblPrice, spnPrice);
    properties.addTerminator();
}
 
开发者ID:SunakazeKun,项目名称:PMDe,代码行数:31,代码来源:AreaEditor.java

示例14: itemStateChanged

import javax.swing.JComboBox; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void itemStateChanged(ItemEvent e) {
    // When the unit type changes, we have to reset the role choices
    JComboBox<String> box = this.roleUI.getComponent();
    DefaultComboBoxModel<String> model;
    boolean enable = false;
    UnitType type = (UnitType)this.typeUI.getComponent().getSelectedItem();
    if (type != null && type.hasAbility(Ability.CAN_BE_EQUIPPED)) {
        final Specification spec = type.getSpecification();
        final NationType nt = getOption().getNationType();
        int n = 0;
        model = new DefaultComboBoxModel<>();
        for (String ri : getOption().getRole().getChoices()) {
            Role role = spec.getRole(ri);
            if (role.isAvailableTo(type, nt)) {
                model.addElement(ri);
                n++;
            }
        }
        enable = isEditable() && n > 1;
    } else {
        model = new DefaultComboBoxModel<>(new String[] {
                Specification.DEFAULT_ROLE_ID });
    }
    box.setModel(model);
    box.setEnabled(enable);
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:31,代码来源:AbstractUnitOptionUI.java

示例15: connect

import javax.swing.JComboBox; //导入方法依赖的package包/类
/**
 * Connects a combo box with the list of dbschemas in a project, making
 * the combo box display these dbschemas.
 */
public static void connect(JComboBox comboBox, DBSchemaFileList dbschemaFileList) {
    comboBox.setModel(new DBSchemaModel(dbschemaFileList));
    comboBox.setRenderer(new DBSchemaRenderer(comboBox));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:DBSchemaUISupport.java


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