本文整理了Java中javax.swing.JComboBox.insertItemAt()
方法的一些代码示例,展示了JComboBox.insertItemAt()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JComboBox.insertItemAt()
方法的具体详情如下:
包路径:javax.swing.JComboBox
类名称:JComboBox
方法名:insertItemAt
暂无
代码示例来源: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
cbExpansionSet.insertItemAt(message, 0);
cbExpansionSet.setSelectedIndex(0);
代码示例来源:origin: mucommander/mucommander
@Override
public void insertItemAt(Object object, int i) {
ignoreActionEvent = true;
super.insertItemAt(object, i);
ignoreActionEvent = false;
}
代码示例来源:origin: com.fifesoft.rtext/fife.common
/**
* Inserts an item at the specified location in the combo box's list.
* This method should be used instead of <code>JComboBox</code>'s
* <code>insertItemAt</code> method.
*
* @param label The label of the entry to insert.
* @param index The index at which to add the object.
* @param value The value of the entry to insert.
*/
public void insertLabelValueAt(L label, int index, V value) {
values.add(index, value);
super.insertItemAt(label, index);
}
代码示例来源:origin: net.java.abeille/abeille
/**
* Adds a color to the view that is not in the color manager
*/
public void prependColor(String key, Color c) {
if (key == null)
return;
/** insert after the 'constant' entry */
m_key_combo.insertItemAt(new ColorCellValue(key, c), 1);
}
代码示例来源:origin: RPTools/maptool
private void installHotKeyCombo() {
String[] hotkeys = MacroButtonHotKeyManager.HOTKEYS;
JComboBox combo = panel.getComboBox("hotKey");
for (int i = 0; i < hotkeys.length; i++)
combo.insertItemAt(hotkeys[i], i);
}
代码示例来源:origin: de.sciss/scisslib
public void insertItemAt( Object item, int index )
{
super.insertItemAt( validateItem( item ), index );
}
代码示例来源:origin: senbox-org/snap-desktop
private void populateRepositoryListCombo(final ProductLibraryConfig config) {
// add default repositories
repositoryFolderStartIndex = 0;
repositoryListCombo.insertItemAt(new FolderRepository(DBQuery.ALL_FOLDERS, null), repositoryFolderStartIndex++);
repositoryListCombo.insertItemAt(new ScihubRepository(), repositoryFolderStartIndex++);
// add previously added folder repositories
final File[] baseDirList = config.getBaseDirs();
for (File f : baseDirList) {
repositoryListCombo.insertItemAt(new FolderRepository(f.getAbsolutePath(), f), repositoryListCombo.getItemCount());
}
repositoryListCombo.setSelectedIndex(0);
}
代码示例来源:origin: org.junit/com.springsource.junit
private void addToHistory(final String suite) {
for (int i= 0; i < fSuiteCombo.getItemCount(); i++) {
if (suite.equals(fSuiteCombo.getItemAt(i))) {
fSuiteCombo.removeItemAt(i);
fSuiteCombo.insertItemAt(suite, 0);
fSuiteCombo.setSelectedIndex(0);
return;
}
}
fSuiteCombo.insertItemAt(suite, 0);
fSuiteCombo.setSelectedIndex(0);
pruneHistory();
}
代码示例来源:origin: senbox-org/snap-desktop
private void populateRepositoryListCombo(final ProductLibraryConfig config) {
// add default repositories
repositoryListCombo.insertItemAt(new FolderRepository(DBQuery.ALL_FOLDERS, null), 0);
repositoryListCombo.insertItemAt(new ScihubRepository(), 1);
// add previously added folder repositories
final File[] baseDirList = config.getBaseDirs();
for (File f : baseDirList) {
repositoryListCombo.insertItemAt(new FolderRepository(f.getAbsolutePath(), f), repositoryListCombo.getItemCount());
}
if (baseDirList.length > 0) {
repositoryListCombo.setSelectedIndex(0);
}
}
代码示例来源:origin: openpnp/openpnp
public void addCamera(Camera camera) {
CameraView cameraView = new CameraView();
cameraView.setCamera(camera);
cameraViews.put(camera, cameraView);
camerasCombo.addItem(new CameraItem(camera));
if (cameraViews.size() == 1) {
// First camera being added, so select it
camerasCombo.setSelectedIndex(1);
}
else if (cameraViews.size() == 2) {
// Otherwise this is the second camera so mix in the
// show all item.
camerasCombo.insertItemAt(SHOW_ALL_ITEM_H, 1);
camerasCombo.insertItemAt(SHOW_ALL_ITEM_V, 2);
}
}
代码示例来源:origin: senbox-org/snap-desktop
private RepositoryInterface addToRepositoryListCombo(final File baseDir) {
RepositoryInterface repo = getRepositoryFromListCombo(baseDir);
if (repo == null) {
repo = new FolderRepository(baseDir.getAbsolutePath(), baseDir);
repositoryListCombo.insertItemAt(repo, repositoryListCombo.getItemCount());
}
return repo;
}
代码示例来源:origin: RPTools/maptool
private void installColorCombo() {
JComboBox combo = panel.getComboBox("colorComboBox");
combo.setModel(new DefaultComboBoxModel(MapToolUtil.getColorNames().toArray()));
combo.insertItemAt("default", 0);
combo.setSelectedItem("default");
combo.setRenderer(new ColorComboBoxRenderer());
}
代码示例来源:origin: bspkrs/MCPMappingViewer
@Override
public void actionPerformed(ActionEvent e)
{
if (e.getActionCommand().equals("comboBoxEdited"))
{
String filterText = cmbFilter.getSelectedItem().toString();
if (filterText == null || filterText.trim().isEmpty())
return;
DefaultComboBoxModel<String> model = (DefaultComboBoxModel<String>) cmbFilter.getModel();
if (model.getIndexOf(filterText) != -1)
model.removeElement(filterText);
cmbFilter.insertItemAt(filterText, 0);
cmbFilter.setSelectedItem(filterText);
}
}
}
代码示例来源:origin: bcdev/beam
/**
* Implementation should handle that a new
* <code>Repository<code> was added.
*
* @param repository the <code>Repository<code> that was added.
*/
public void repositoryAdded(final Repository repository) {
repositoryList.insertItemAt(repository, repositoryList.getItemCount());
pgConfig.setRepositories(repositoryManager.getRepositories());
}
代码示例来源:origin: edu.toronto.cs.medsavant/medsavant-client
@Override
public void addItem(Object anObject) {
int size = ((DefaultComboBoxModel) dataModel).getSize();
Object obj;
boolean added = false;
for (int i = 0; i < size; i++) {
obj = dataModel.getElementAt(i);
int compare = anObject.toString().compareToIgnoreCase(obj.toString());
if (compare <= 0) { // if anObject less than or equal obj
super.insertItemAt(anObject, i);
added = true;
break;
}
}
if (!added) {
super.addItem(anObject);
}
}
};
代码示例来源:origin: NetSPI/AWSSigner
public void createNewProfile() {
// Add another profile to the combo box, or add the add profile button if it's not already there.
int boxSize = profileComboBox.getItemCount();
if (boxSize == 0) {
// If there's nothing here, just add our add profile button
this.profileComboBox.addItem(new AWSSignerMenuItem("Add Profile", 0));
} else {
// If there is already an add profile button, start creating profiles
numProfiles++;
profileComboBox.insertItemAt(new AWSSignerMenuItem("Profile " + numProfiles, numProfiles), boxSize - 1);
profiles.put(numProfiles, new String[]{"", "", "", ""});
profileComboBox.setSelectedIndex(boxSize-1);
clearProfile();
setMenuItems();
}
}
代码示例来源:origin: thiagotts/CloudReports
/** Creates a new RemoveDatacenter form. */
public RemoveDatacenter(CloudTree tree) {
this.tree=tree;
initComponents();
int i=0;
DatacenterRegistryDAO drDAO = new DatacenterRegistryDAO();
for(DatacenterRegistry d : drDAO.getListOfDatacenters()) {
jComboBox1.insertItemAt(d.getName(), i);
i++;
}
}
代码示例来源:origin: thiagotts/CloudReports
/** Creates a new RemoveUserGroup form. */
public RemoveCustomer(CloudTree tree) {
this.tree=tree;
initComponents();
int i=0;
CustomerRegistryDAO crDAO = new CustomerRegistryDAO();
for(CustomerRegistry c : crDAO.getListOfCustomers()) {
jComboBox1.insertItemAt(c.getName(), i);
i++;
}
}
代码示例来源:origin: org.cytoscape/table-import-impl
private void browseOntologyButtonActionPerformed(java.awt.event.ActionEvent evt) {
DataSourceSelectDialog dssd = new DataSourceSelectDialog(DataSourceSelectDialog.ONTOLOGY_TYPE,
CytoscapeServices.cySwingApplication.getJFrame(), Dialog.ModalityType.APPLICATION_MODAL, fileUtil);
dssd.setLocationRelativeTo(CytoscapeServices.cySwingApplication.getJFrame());
dssd.setVisible(true);
String key = dssd.getSourceName();
if (key != null) {
panel.ontologyComboBox.insertItemAt(key, 0);
panel.ontologyUrlMap.put(key, dssd.getSourceUrlString());
panel.ontologyComboBox.setSelectedItem(key);
panel.ontologyComboBox.setToolTipText(getOntologyTooltip());
}
}
内容来源于网络,如有侵权,请联系作者删除!