Colocar ação em botão (deitel cap. 31)

Boa noite pessoal. Alguém pode me dar uma mão neste código do Deitel, cap 31. O botão não executa ação nenhuma…


package welcomesoapclient;

import welcome.WelcomeSOAP;
import welcome.WelcomeSOAPService;
import javax.swing.JOptionPane;

public class WelcomeSOAPClientJFrame extends javax.swing.JFrame {

    private WelcomeSOAP welcomeSOAPProxy;

    /** Creates new form WelcomeSOAPClientJFrame */
    public WelcomeSOAPClientJFrame() {
        initComponents();

        try {
            WelcomeSOAPService service = new WelcomeSOAPService();
            welcomeSOAPProxy = service.getWelcomeSOAPPort();
            System.out.println("try");
        } catch (Exception exception){
            exception.printStackTrace();
            System.exit(1);
        }
    }

    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        nameJLabel = new javax.swing.JLabel();
        submitJButton = new javax.swing.JButton();
        nameJTextField = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        nameJLabel.setText("Nome:");

        submitJButton.setText("Submit");
        submitJButton.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                submitJButtonActionPerformed(evt);
            }
        });

        nameJTextField.setText("jTextField1");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(41, 41, 41)
                        .addComponent(nameJLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(nameJTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(128, 128, 128)
                        .addComponent(submitJButton)))
                .addContainerGap(207, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(40, 40, 40)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nameJLabel)
                    .addComponent(nameJTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(74, 74, 74)
                .addComponent(submitJButton)
                .addContainerGap(143, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>

    private void submitJButtonActionPerformed(java.awt.event.KeyEvent evt) {
        String name = nameJTextField.getText();
        System.out.println("submit");

        String message = welcomeSOAPProxy.welcome(name);
        JOptionPane.showMessageDialog(this, message, "Welcome", JOptionPane.INFORMATION_MESSAGE);
    }

   public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new WelcomeSOAPClientJFrame().setVisible(true);
                System.out.println("main");
            }
        }
        );
    }

    // Variables declaration - do not modify
    private javax.swing.JLabel nameJLabel;
    private javax.swing.JTextField nameJTextField;
    private javax.swing.JButton submitJButton;
    // End of variables declaration

}

Grato…

Você já tentou digitar qualquer caractere do teclado quando o foco está no botão?

Entenda a interface KeyListener

Esta interface é usada para receber eventos do teclado (pressionamento de teclas). Classes interessadas em processar eventos do teclado devem implementar esta interface (e todos os seus métodos) ou extender a classe abstrata KeyAdapter (sobrescrevendo apenas os métodos de interesse).