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


Java JComboBox.removeItem方法代码示例

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


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

示例1: 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());
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:23,代码来源:PrologDisplay.java

示例2: actionPerformed

import javax.swing.JComboBox; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) {
	JComboBox<Database> databasesCombo = getSelectedDatabaseViewer().getCombo();
	JCheckBox dropOnDbmsCheckBox = new JCheckBox("Drop database on DBMS too", true);
	
	// There must be at least one database
	if (databasesCombo.getItemCount() > 1) {
		Database databaseToRemove = (Database)
				getSelectedDatabaseViewer().getCombo().getSelectedItem();
		
		String message = "Are you sure you want to drop the database '" + 
				databaseToRemove.getName() + "'?\n\n";
		Object[] params = { message, dropOnDbmsCheckBox };
		
		// Confirm deletion
		int dialogResult = JOptionPane.showConfirmDialog (null, 
				params,
				"Confirm Deletion",
				JOptionPane.YES_NO_OPTION);
		
		if(dialogResult == JOptionPane.YES_OPTION){
			databasesCombo.removeItem((Database) databaseToRemove);
			System.out.println("> Database '" + databaseToRemove.getName() + "' was dropped.");
			
			// Drop it from DBMS?
			if (dropOnDbmsCheckBox.isSelected()) {
				try {
					
					// Switch to an existing database
					String existingDatabaseName = getSelectedDatabaseViewer()
							.getSelectedDatabase().getName();
					getSelectedDatabaseViewer().getSelectedDatabase().getDbmsDriver()
						.switchDatabase(existingDatabaseName);
					
					getSelectedDatabaseViewer().getSelectedDatabase().getDbmsDriver()
					.dropDatabase(databaseToRemove.getName());
				} catch (SQLException e1) {
					e1.printStackTrace();
				}
			}
		}
	}
	
	else {
		JOptionPane.showMessageDialog(DatabaseViewer.this.getParent(), 
				"There must be at least one database.", 
				"Warning", 
				JOptionPane.INFORMATION_MESSAGE);
	}
}
 
开发者ID:tteguayco,项目名称:JITRAX,代码行数:50,代码来源:DatabaseViewer.java


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