本文整理汇总了Java中javax.swing.JComboBox.getItemCount方法的典型用法代码示例。如果您正苦于以下问题:Java JComboBox.getItemCount方法的具体用法?Java JComboBox.getItemCount怎么用?Java JComboBox.getItemCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JComboBox
的用法示例。
在下文中一共展示了JComboBox.getItemCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setFilterResultItem
import javax.swing.JComboBox; //导入方法依赖的package包/类
/** Adds or removes an item for {@link Filter#RESULT} to the filter chooser. */
private void setFilterResultItem(boolean hasResults) {
JComboBox<Filter> chooser = getFilterChooser();
if (hasResults != (chooser.getItemCount() == Filter.values().length)) {
this.filterListening = false;
boolean resultSelected = chooser.getSelectedIndex() == Filter.RESULT.ordinal();
if (hasResults) {
chooser.addItem(Filter.RESULT);
} else {
chooser.removeItemAt(Filter.RESULT.ordinal());
}
if (resultSelected) {
chooser.setSelectedIndex(Filter.NONE.ordinal());
}
getJGraph().setFilter(Filter.NONE);
this.filterListening = true;
}
}
示例2: initPlatformCombo
import javax.swing.JComboBox; //导入方法依赖的package包/类
protected static void initPlatformCombo(JComboBox combo) {
if (combo == null){
return;
}
if (combo.getItemCount() <= 0) {
return;
}
boolean set = false;
String idToSelect = ModuleUISettings.getDefault().getLastUsedPlatformID();
for (int i = 0; i < combo.getItemCount(); i++) {
if (((NbPlatform) combo.getItemAt(i)).getID().equals(idToSelect)) {
combo.setSelectedIndex(i);
set = true;
break;
}
}
if (!set) {
NbPlatform defPlaf = NbPlatform.getDefaultPlatform();
combo.setSelectedItem(defPlaf == null ? combo.getItemAt(0) : defPlaf);
}
}
示例3: searchLIPCategoryCombo
import javax.swing.JComboBox; //导入方法依赖的package包/类
/**
* Searches LayerItemPresenter combobox by the item's display name.
*/
private static String searchLIPCategoryCombo(final JComboBox lpCombo, final String displayName) {
String path = null;
for (int i = 0; i < lpCombo.getItemCount(); i++) {
Object item = lpCombo.getItemAt(i);
if (!(item instanceof LayerItemPresenter)) {
continue;
}
LayerItemPresenter presenter = (LayerItemPresenter) lpCombo.getItemAt(i);
if (displayName.equals(presenter.getDisplayName())) {
path = presenter.getFullPath();
break;
}
}
return path;
}
示例4: addQueryHistory
import javax.swing.JComboBox; //导入方法依赖的package包/类
/**
* Add the query to the history
*/
private void addQueryHistory(String queryString) {
JComboBox<String> query = getQueryField();
query.removeItem(queryString);
query.insertItemAt(queryString, 0);
query.setSelectedIndex(0);
while (query.getItemCount() > MAX_HISTORY) {
query.removeItemAt(MAX_HISTORY);
}
// store the history
StringBuilder sb = new StringBuilder();
for (int i = 0; i < query.getItemCount(); i++) {
if (i > 0) {
sb.append("\n");
}
sb.append(query.getItemAt(i));
}
PREFS.put("queryHistory", sb.toString());
}
示例5: selectInJCombo
import javax.swing.JComboBox; //导入方法依赖的package包/类
public static <T> int selectInJCombo(JComboBox<T> combo, T obj, int defaultSelectIndex)
{
int i = selectInJCombo(combo, obj);
if( i >= 0 )
{
return i;
}
else
{
int count = combo.getItemCount();
if( defaultSelectIndex < count )
{
combo.setSelectedIndex(defaultSelectIndex);
}
else if( count > 0 )
{
combo.setSelectedIndex(count - 1);
}
return combo.getSelectedIndex();
}
}
示例6: getDump
import javax.swing.JComboBox; //导入方法依赖的package包/类
/**
* Returns information about component.
*/
@Override
public Hashtable<String, Object> getDump() {
Hashtable<String, Object> result = super.getDump();
JComboBox<?> jComboBox = (JComboBox<?>) getSource();
Object selectedItem = jComboBox.getSelectedItem();
if (selectedItem != null) {
result.put(TEXT_DPROP, selectedItem.toString());
}
int itemCount = jComboBox.getItemCount();
String[] items = new String[itemCount];
for (int i = 0; i < itemCount; i++) {
if (jComboBox.getItemAt(i) != null) {
items[i] = jComboBox.getItemAt(i).toString();
}
}
addToDump(result, ITEM_PREFIX_DPROP, items);
return result;
}
示例7: bindMatchTypeComboBox
import javax.swing.JComboBox; //导入方法依赖的package包/类
/**
* Bind Match Type option to a combo box.
*
* @param comboBox Combo box to control and display the match type. The
* model of the combo box can contain only items of type {@link MatchType}.
* {@link MatchType#LITERAL} and {@link MatchType#REGEXP} are mandatory in
* the model.
*
* @since api.search/1.11
*/
public void bindMatchTypeComboBox(@NonNull final JComboBox comboBox) {
Parameters.notNull("comboBox", comboBox); //NOI18N
boolean regexpFound = false, literalFound = false;
for (int i = 0; i < comboBox.getItemCount(); i++) {
if (comboBox.getItemAt(i) == MatchType.LITERAL) {
literalFound = true;
} else if (comboBox.getItemAt(i) == MatchType.REGEXP) {
regexpFound = true;
} else if (!(comboBox.getItemAt(i) instanceof MatchType)) {
throw new IllegalArgumentException("Model of the combo "//NOI18N
+ "box can contain only MatchType items"); //NOI18N
}
}
if (!(regexpFound && literalFound)) {
throw new IllegalArgumentException(
"At least MatchType.LITERAL and MatchType.REGEXP " //NOI18N
+ "must be contained in the combo box model."); //NOI18N
}
if (matchTypeComboBox != null) {
throw new IllegalStateException(
"Already bound with option MATCH_TYPE"); //NOI18N
}
this.matchTypeComboBox = comboBox;
comboBox.setEditable(false);
setMatchType(this.matchType); //update match type, check it is supported
comboBox.setSelectedItem(matchType);
comboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
setMatchType((MatchType) comboBox.getSelectedItem());
}
});
}
示例8: setSelectedConnection
import javax.swing.JComboBox; //导入方法依赖的package包/类
/**
* Sets the selected item in connection combo box.
*/
private void setSelectedConnection(){
DatabaseConnection connection = ProviderUtil.getConnection(persistenceUnit);
if (connection != null){
jdbcComboBox.setSelectedItem(connection);
} else {
// custom connection (i.e. connection not registered in netbeans)
Properties props = persistenceUnit.getProperties();
if (props != null){
Property[] properties = props.getProperty2();
String url = null;
ArrayList<Provider> providers = new ArrayList<Provider>();
JComboBox activeCB = providerCombo.isVisible() ? providerCombo : libraryComboBox;
for(int i=0; i<activeCB.getItemCount(); i++){
Object obj = activeCB.getItemAt(i);
if(obj instanceof Provider){
providers.add((Provider) obj);
}
}
Provider provider = ProviderUtil.getProvider(persistenceUnit, providers.toArray(new Provider[]{}));
for (int i = 0; i < properties.length; i++) {
String key = properties[i].getName();
if (provider.getJdbcUrl().equals(key)) {
url = properties[i].getValue();
break;
}
}
if (url == null) {
url = NbBundle.getMessage(PersistenceUnitPanel.class, "LBL_CustomConnection");//NOI18N
}
jdbcComboBox.addItem(url);
jdbcComboBox.setSelectedItem(url);
}
}
}
示例9: getItems
import javax.swing.JComboBox; //导入方法依赖的package包/类
protected List<String> getItems(JComboBoxOperator boxOperator){
JComboBox box = (JComboBox) boxOperator.getSource();
int boxSize = box.getItemCount();
List<String> result = new ArrayList<String>(boxSize);
for(int i = 0;i < boxSize; i++){
result.add(box.getModel().getElementAt(i).toString());
}
return result;
}
示例10: getColor
import javax.swing.JComboBox; //导入方法依赖的package包/类
static Color getColor (JComboBox<ColorValue> combo) {
// The last item is Inherited Color or None
if (combo.getSelectedIndex() < combo.getItemCount() - 1) {
return ((ColorValue) combo.getSelectedItem()).color;
} else {
return null;
}
}
示例11: createOperatorCombo
import javax.swing.JComboBox; //导入方法依赖的package包/类
private JComboBox createOperatorCombo(final PropertyTable propertyTable) {
List<Operator> allInnerOps = parentOperator.getAllInnerOperators();
Vector<String> allOpNames = new Vector<String>();
Iterator<Operator> i = allInnerOps.iterator();
while (i.hasNext()) {
allOpNames.add(i.next().getName());
}
Collections.sort(allOpNames);
final JComboBox combo = new JComboBox(allOpNames);
combo.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
String operatorName = (String) combo.getSelectedItem();
panel.remove(parameterCombo);
parameterCombo = createParameterCombo(operatorName, propertyTable);
panel.add(parameterCombo);
fireParameterChangedEvent();
fireEditingStopped();
}
});
if (combo.getItemCount() == 0) {
combo.addItem("add inner operators");
} else {
combo.setSelectedIndex(0);
}
return combo;
}
示例12: createParameterCombo
import javax.swing.JComboBox; //导入方法依赖的package包/类
private JComboBox createParameterCombo(String operatorName, PropertyTable propertyTable) {
JComboBox combo = new JComboBox();
Operator operator = process.getOperator((String) operatorCombo.getSelectedItem());
if (operator != null) {
Iterator<ParameterType> i = operator.getParameters().getParameterTypes().iterator();
while (i.hasNext()) {
combo.addItem(i.next().getKey());
}
}
if (combo.getItemCount() == 0) {
combo.addItem("no parameters");
}
combo.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
fireParameterChangedEvent();
fireEditingStopped();
}
});
combo.setSelectedIndex(0);
return combo;
}
示例13: findIndexInCombo
import javax.swing.JComboBox; //导入方法依赖的package包/类
private static <T> int findIndexInCombo(JComboBox<T> combo, T obj)
{
final int count = combo.getItemCount();
for( int i = 0; i < count; i++ )
{
Object comboObject = combo.getItemAt(i);
if( Objects.equals(comboObject, obj) )
{
return i;
}
}
return -1;
}
示例14: verifyWholeBox
import javax.swing.JComboBox; //导入方法依赖的package包/类
/**
* Verify the contents of the JComboBox.
*
* @return True if all is well.
*/
private boolean verifyWholeBox(JComboBox<Integer> box) {
final int n = box.getItemCount();
for (int i = 0; i < n; i++) {
Integer v = box.getItemAt(i);
if (v < 0 || v > available) return false;
}
return true;
}
示例15: LimpiarCombo
import javax.swing.JComboBox; //导入方法依赖的package包/类
public void LimpiarCombo(JComboBox combo) // COMPLETO
{
int filas = combo.getItemCount(); // cuenta numero de filas q tiene la tabla
for(int i=0; i<filas; i++)
{
combo.removeItemAt(0);// valor fijo de 0
}
}