本文整理了Java中javax.swing.JComboBox.getItemAt()
方法的一些代码示例,展示了JComboBox.getItemAt()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JComboBox.getItemAt()
方法的具体详情如下:
包路径:javax.swing.JComboBox
类名称:JComboBox
方法名:getItemAt
暂无
代码示例来源:origin: groovy/groovy-core
/**
* Support the subscript operator for JComboBox.
*
* @param self a JComboBox
* @param index the index of the item to get
* @return the tem at the given index
* @since 1.6.4
*/
public static Object getAt(JComboBox self, int index) {
return self.getItemAt(index);
}
代码示例来源: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: 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: 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: 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: magefree/mage
private void cbExpansionSetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbExpansionSetActionPerformed
if (!cbExpansionSet.getSelectedItem().toString().contains(TEST_MULTI_SET)) {
int index = cbExpansionSet.getSelectedIndex();
if (cbExpansionSet.getItemAt(0).contains(TEST_MULTI_SET)) {
cbExpansionSet.removeItemAt(0);
index--;
}
listCodeSelected.uncheckAll();
if (index > 0) {
//ofset because all sets is removed from the list
listCodeSelected.setChecked(index - 1, true);
}
}
filterCards();
}//GEN-LAST:event_cbExpansionSetActionPerformed
代码示例来源:origin: magefree/mage
if (cbExpansionSet.getItemAt(index).equals(itemSelected)) {
cbExpansionSet.setSelectedIndex(index);
cbExpansionSet.setSelectedIndex(0);
if (cbExpansionSet.getItemAt(1).contains(TEST_MULTI_SET)) {
cbExpansionSet.removeItemAt(1);
代码示例来源:origin: magefree/mage
String item;
for (int i = 0; i < cbLandSet.getItemCount(); i++) {
item = (String) cbLandSet.getItemAt(i);
if (item.equalsIgnoreCase(defaultSetName)) {
cbLandSet.setSelectedIndex(i);
代码示例来源:origin: Audiveris/audiveris
private FilterKind readKind ()
{
return kindCombo.getItemAt(kindCombo.getSelectedIndex());
}
}
代码示例来源:origin: igniterealtime/Spark
/**
* Returns the name of the theme selected.
*
* @return the name of the selected theme.
*/
public String getSelectedTheme()
{
return messageStyleBox.getItemAt( messageStyleBox.getSelectedIndex() );
}
代码示例来源:origin: winder/Universal-G-Code-Sender
Language l = languageCombo.getItemAt(i);
if (l.getLanguageCode().equals(s.getLanguage())) {
languageCombo.setSelectedIndex(i);
代码示例来源: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: protegeproject/protege
public Optional<ViewMode> getViewMode() {
if(viewModes.isEmpty()) {
return Optional.empty();
}
int selIndex = viewModeComboBox.getSelectedIndex();
if(selIndex == -1) {
return Optional.empty();
}
return Optional.of(viewModeComboBox.getItemAt(selIndex));
}
代码示例来源:origin: org.apache.jmeter/jorphan
@Override
public void actionPerformed(ActionEvent e) {
String item = (String) choiceList.getSelectedItem();
int index = choiceList.getSelectedIndex();
if (!item.equals(choiceList.getItemAt(index))) {
choiceList.addItem(item);
}
choiceList.setSelectedItem(item);
notifyChangeListeners();
}
}
代码示例来源:origin: Audiveris/audiveris
@Override
public void actionPerformed (ActionEvent e)
{
PluginsManager.defaultPluginId.setSpecific(box.getItemAt(box.getSelectedIndex()));
}
}
代码示例来源:origin: Audiveris/audiveris
@Override
public void actionPerformed (ActionEvent e)
{
Step step = box.getItemAt(box.getSelectedIndex());
StubsController.setEarlyStep(step);
}
}
代码示例来源: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: org.cytoscape/vizmap-gui-impl
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
try {
if ((combo.getSelectedItem() == null) && (combo.getItemCount() != 0)) {
combo.setSelectedIndex(0);
firePropertyChange(oldValue, combo.getItemAt(0));
} else
firePropertyChange(oldValue, combo.getSelectedItem());
} catch (Exception ex) {
ex.printStackTrace();
}
}
代码示例来源:origin: jsettlers/settlers-remake
public void setPlayerType(EPlayerType playerType, boolean enabled) {
for (int i = 0; i < typeComboBox.getItemCount(); i++) {
if (typeComboBox.getItemAt(i).getPlayerType() == playerType) {
typeComboBox.setSelectedIndex(i);
break;
}
}
typeComboBox.setEnabled(enabled);
updateAiPlayerName();
}
代码示例来源: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();
}
内容来源于网络,如有侵权,请联系作者删除!