當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。