本文整理了Java中javax.swing.JComboBox.getItemCount()
方法的一些代码示例,展示了JComboBox.getItemCount()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JComboBox.getItemCount()
方法的具体详情如下:
包路径:javax.swing.JComboBox
类名称:JComboBox
方法名:getItemCount
暂无
代码示例来源:origin: groovy/groovy-core
/**
* Provide the standard Groovy <code>size()</code> method for <code>JComboBox</code>.
*
* @param self a JComboBox
* @return the intem count of the comboBox
* @since 1.6.4
*/
public static int size(JComboBox self) {
return self.getItemCount();
}
代码示例来源:origin: log4j/log4j
/**
* Changes the font selection in the combo box and returns the
* size actually selected.
* @return -1 if unable to select an appropriate font
*/
protected int changeFontSizeCombo(JComboBox box, int requestedSize) {
int len = box.getItemCount();
int currentValue;
Object currentObject;
Object selectedObject = box.getItemAt(0);
int selectedValue = Integer.parseInt(String.valueOf(selectedObject));
for (int i = 0; i < len; i++) {
currentObject = box.getItemAt(i);
currentValue = Integer.parseInt(String.valueOf(currentObject));
if (selectedValue < currentValue && currentValue <= requestedSize) {
selectedValue = currentValue;
selectedObject = currentObject;
}
}
box.setSelectedItem(selectedObject);
return selectedValue;
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
/**
* <code>updateResolutionChoices</code> updates the available resolutions
* list to match the currently selected window mode (fullscreen or
* windowed). It then sets up a list of standard options (if windowed) or
* calls <code>updateDisplayChoices</code> (if fullscreen).
*/
private void updateResolutionChoices() {
if (!fullscreenBox.isSelected()) {
displayResCombo.setModel(new DefaultComboBoxModel(
getWindowedResolutions(windowModes)));
if (displayResCombo.getItemCount() > 0) {
displayResCombo.setSelectedIndex(displayResCombo.getItemCount()-1);
}
colorDepthCombo.setModel(new DefaultComboBoxModel(new String[]{
"24 bpp", "16 bpp"}));
displayFreqCombo.setModel(new DefaultComboBoxModel(
new String[]{resourceBundle.getString("refresh.na")}));
displayFreqCombo.setEnabled(false);
} else {
displayResCombo.setModel(new DefaultComboBoxModel(
getResolutions(modes, Integer.MAX_VALUE, Integer.MAX_VALUE)));
if (displayResCombo.getItemCount() > 0) {
displayResCombo.setSelectedIndex(displayResCombo.getItemCount()-1);
}
displayFreqCombo.setEnabled(true);
updateDisplayChoices();
}
}
代码示例来源:origin: groovy/groovy-core
private static void setListStrings() {
Object findObject = FIND_FIELD.getSelectedItem();
Object replaceObject = REPLACE_FIELD.isShowing() ?
(String) REPLACE_FIELD.getSelectedItem() : "";
if (findObject != null && replaceObject != null) {
boolean found = false;
for (int i = 0; !found && i < FIND_FIELD.getItemCount(); i++) {
found = FIND_FIELD.getItemAt(i).equals(findObject);
}
if (!found) {
FIND_FIELD.insertItemAt(findObject, 0);
if (FIND_FIELD.getItemCount() > 7) {
FIND_FIELD.removeItemAt(7);
}
}
if (REPLACE_FIELD.isShowing()) {
found = false;
for (int i = 0; !found && i < REPLACE_FIELD.getItemCount(); i++) {
found = REPLACE_FIELD.getItemAt(i).equals(findObject);
}
if (!found) {
REPLACE_FIELD.insertItemAt(replaceObject, 0);
if (REPLACE_FIELD.getItemCount() > 7) {
REPLACE_FIELD.removeItemAt(7);
}
}
}
}
}
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
public void run() {
// Fill in the combos once the window has opened so that the insets can be read.
// The assumption is made that the settings window and the display window will have the
// same insets as that is used to resize the "full screen windowed" mode appropriately.
updateResolutionChoices();
if (source.getWidth() != 0 && source.getHeight() != 0) {
displayResCombo.setSelectedItem(source.getWidth() + " x "
+ source.getHeight());
} else {
displayResCombo.setSelectedIndex(displayResCombo.getItemCount()-1);
}
updateAntialiasChoices();
colorDepthCombo.setSelectedItem(source.getBitsPerPixel() + " bpp");
}
});
代码示例来源:origin: magefree/mage
private void selectLimitedByDefault() {
for (int i = 0; i < cbDeckType.getItemCount(); i++) {
String name = (String) cbDeckType.getItemAt(i);
if (name.equals(LIMITED)) {
cbDeckType.setSelectedIndex(i);
break;
}
}
}
代码示例来源:origin: magefree/mage
public void init(int playerNum, PlayerType playerType) {
cbPlayerType.setModel(new DefaultComboBoxModel(SessionHandler.getPlayerTypes()));
this.lblPlayerNum.setText("Player " + playerNum);
if (Config.defaultOtherPlayerIndex != null) {
if (Integer.valueOf(Config.defaultOtherPlayerIndex) >= cbPlayerType.getItemCount()) {
cbPlayerType.setSelectedIndex(cbPlayerType.getItemCount() - 1);
} else {
Integer index = Integer.parseInt(Config.defaultOtherPlayerIndex);
cbPlayerType.setSelectedIndex(index);
}
}
if (playerType != null) {
this.cbPlayerType.setSelectedItem(playerType);
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* Changes the font selection in the combo box and returns the
* size actually selected.
* @return -1 if unable to select an appropriate font
*/
protected int changeFontSizeCombo(JComboBox box, int requestedSize) {
int len = box.getItemCount();
int currentValue;
Object currentObject;
Object selectedObject = box.getItemAt(0);
int selectedValue = Integer.parseInt(String.valueOf(selectedObject));
for (int i = 0; i < len; i++) {
currentObject = box.getItemAt(i);
currentValue = Integer.parseInt(String.valueOf(currentObject));
if (selectedValue < currentValue && currentValue <= requestedSize) {
selectedValue = currentValue;
selectedObject = currentObject;
}
}
box.setSelectedItem(selectedObject);
return selectedValue;
}
代码示例来源:origin: winterDroid/android-drawable-importer-intellij-plugin
private void updateSizes() {
prepareSpinner(sizeSpinner, sizeActionListener);
List<String> sizes = controller.getSizes();
for (String size : sizes) {
sizeSpinner.addItem(size);
}
sizeSpinner.setEnabled(sizeSpinner.getItemCount() > 1);
initSpinner(sizeSpinner, controller.getSelectedSize(), sizeActionListener);
}
代码示例来源:origin: winterDroid/android-drawable-importer-intellij-plugin
private void updateCategories() {
prepareSpinner(categorySpinner, categoryActionListener);
for (String category : controller.getCategories()) {
categorySpinner.addItem(category);
}
categorySpinner.setEnabled(categorySpinner.getItemCount() > 1);
initSpinner(categorySpinner, controller.getSelectedCategory(), categoryActionListener);
}
代码示例来源:origin: winterDroid/android-drawable-importer-intellij-plugin
private void updateCategories() {
prepareSpinner(categorySpinner, categoryActionListener);
for (String category : controller.getCategories()) {
categorySpinner.addItem(category);
}
categorySpinner.setEnabled(categorySpinner.getItemCount() > 1);
initSpinner(categorySpinner, controller.getSelectedCategory(), categoryActionListener);
}
代码示例来源:origin: magefree/mage
for (int index = 0; index < cbExpansionSet.getItemCount(); index++) {
if (cbExpansionSet.getItemAt(index).equals(itemSelected)) {
cbExpansionSet.setSelectedIndex(index);
代码示例来源:origin: magefree/mage
if (defaultSetName != null) {
String item;
for (int i = 0; i < cbLandSet.getItemCount(); i++) {
item = (String) cbLandSet.getItemAt(i);
if (item.equalsIgnoreCase(defaultSetName)) {
代码示例来源:origin: stackoverflow.com
@Override
public void setPopupVisible(JComboBox c, boolean v) {
// keeps the popup from coming down if there's nothing in the combo box
if (c.getItemCount() > 0) {
super.setPopupVisible(c, v);
}
}
代码示例来源:origin: entertailion/Fling
public void actionPerformed(ActionEvent e) {
// refresh the list of devices
if (deviceList.getItemCount() > 0) {
deviceList.setSelectedIndex(0);
}
discoverDevices();
}
});
代码示例来源:origin: winder/Universal-G-Code-Sender
add(showNightlyWarning, "spanx, wrap");
for (int i = 0; i < languageCombo.getItemCount(); i++) {
Language l = languageCombo.getItemAt(i);
if (l.getLanguageCode().equals(s.getLanguage())) {
代码示例来源:origin: net.java.dev.jets3t/jets3t
private int findBucketIndexByName(String bucketName) {
for (int i = 0; i < loggedToBucketComboBox.getItemCount(); i++) {
String testBucketName = (String) loggedToBucketComboBox.getItemAt(i);
if (testBucketName.equals(bucketName)) {
return i;
}
}
return 0;
}
代码示例来源:origin: net.java.dev.jets3t/jets3t
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
if (awsProductListComboBox.getItemCount() == 0) {
enabled = false;
}
for (int i = 0; i < internalComponents.length; i++) {
internalComponents[i].setEnabled(enabled);
}
}
代码示例来源:origin: jsettlers/settlers-remake
public void setCivilisation(ECivilisation civilisation, boolean enabled) {
for (int i = 0; i < civilisationComboBox.getItemCount(); i++) {
if (civilisationComboBox.getItemAt(i).getCivilisation() == civilisation) {
civilisationComboBox.setSelectedIndex(i);
break;
}
}
civilisationComboBox.setEnabled(enabled);
}
代码示例来源:origin: openpnp/openpnp
public void setSelectedTool(HeadMountable hm) {
selectedTool = hm;
for (int i = 0; i < comboBoxHeadMountable.getItemCount(); i++) {
HeadMountableItem item = (HeadMountableItem) comboBoxHeadMountable.getItemAt(i);
if (item.getItem() == hm) {
comboBoxHeadMountable.setSelectedItem(item);
break;
}
}
updateDros();
}
内容来源于网络,如有侵权,请联系作者删除!