Exemplo n.º 1
0
 protected JComboBox createCombo(String strText, JPanel pnlDisplay) {
   JComboBox cmbMode = new JComboBox(m_aStrMode);
   if (!strText.equalsIgnoreCase(m_aStrMode[0]) && !strText.equalsIgnoreCase(m_aStrMode[1]))
     strText = m_aStrMode[0];
   cmbMode.setSelectedItem(strText);
   pnlDisplay.add(cmbMode);
   return cmbMode;
 }
Exemplo n.º 2
0
  public void keyReleased(KeyEvent e) {
    char ch = e.getKeyChar();
    if (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch)) return;
    int pos = m_editor.getCaretPosition();
    String str = m_editor.getText();
    if (str.length() == 0) return;

    for (int k = 0; k < m_comboBox.getItemCount(); k++) {
      String item = m_comboBox.getItemAt(k).toString();
      if (item.startsWith(str)) {
        m_editor.setText(item);
        m_editor.setCaretPosition(item.length());
        m_editor.moveCaretPosition(pos);
        m_comboBox.setSelectedItem(item);
        break;
      }
    }
  }