'how to make combo box to work with keytyped event in java? [duplicate]

I have a combo box code like this. In this the KeyTyped Event is not firing when I type some thing. Why ? I don't have an idea. Please do help.

JComboBox<?> Occupation = new JComboBox<Object>();
Occupation.addKeyListener(new KeyAdapter() {`
            @Override
            public void keyTyped(KeyEvent e) {
                char c = e.getKeyChar();
                System.out.println(e);
                if(Occupation.getSelectedItem().toString().length() >= 50)
                {
                    e.consume();
                }
                else
                if((Character.isWhitespace(c) ||  c == '.' || c == '&') && Occupation.getSelectedItem().toString().length() == 0)
                {
                    e.consume();
                    return;
                }
                if(Character.isLetter(c) || Character.isWhitespace(c) || Character.isISOControl(c) || c == '.' || c == '&')
                {
                    return;
                }
                else
                {
                    e.consume();
                }
            }
        });
        Occupation.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
        Occupation.setEditable(true);
        Occupation.setFont(new Font("Courier New", Font.PLAIN, 20));
        Occupation.setBounds(150, 462, 620, 29);
        contentPane.add(Occupation); 


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source