Instead of taking care of my certif. Help me please.
I tried it . here is my code:
I writed a class.
But i didn't understand it why it doesn't work.
class MyKeyAdapter extends KeyAdapter
{
public JComboBox jc;
public JTextField jt;
public Vector v = new Vector();
public MyKeyAdapter(JComboBox combobox)
{
this.jc = combobox;
jt = (JTextField)combobox.getEditor().getEditorComponent();
jt.addKeyListener(this);
}
public void keyTyped(KeyEvent e)
{
char ch = e.getKeyChar();
if (ch == KeyEvent.CHAR_UNDEFINED || Character.isISOControl(ch))
return;
int pos = jt.getCaretPosition();
String str = jt.getText();
for (int i = 0 ; i < jc.getItemCount(); i++)
{
String item =jc.getItemAt(i).toString();
if(item.startsWith(str))
{
System.out.println(item);
jt.setText(item);
jt.setCaretPosition(item.length());
jt.moveCaretPosition(pos) ;
break;
}
}
}