Formulário

public class aClasse extends javax.swing.JFrame {

/** Creates new form aClasse */
private String aCodCli;
private String aNome;
private String aFone;

/** This method is called from within the constructor to
 * initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
private void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;

    LCodigo = new javax.swing.JLabel();
    LNome = new javax.swing.JLabel();
    LFone = new javax.swing.JLabel();
    ECodCli = new javax.swing.JTextField();
    ENome = new javax.swing.JTextField();
    EFone = new javax.swing.JTextField();
    BSair = new javax.swing.JButton();

    getContentPane().setLayout(null);

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("Formul\u00e1rio de teste");
    setName("FCadastro");
    LCodigo.setText("C\u00f3digo");
    getContentPane().add(LCodigo);
    LCodigo.setBounds(10, 10, 44, 15);

    LNome.setText("Nome");
    getContentPane().add(LNome);
    LNome.setBounds(10, 80, 37, 15);

    LFone.setText("Telefone");
    getContentPane().add(LFone);
    LFone.setBounds(10, 150, 60, 15);

    ECodCli.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            ECodCliActionPerformed(evt);
        }
    });

    getContentPane().add(ECodCli);
    ECodCli.setBounds(10, 30, 130, 20);

    getContentPane().add(ENome);
    ENome.setBounds(10, 100, 250, 20);

    getContentPane().add(EFone);
    EFone.setBounds(10, 170, 130, 20);

    BSair.setText("Sair");
    getContentPane().add(BSair);
    BSair.setBounds(340, 270, 57, 23);

    pack();
    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    java.awt.Dimension dialogSize = getSize();
    setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-dialogSize.height)/2);
}

private void ECodCliActionPerformed(java.awt.event.ActionEvent evt) {
    // TODO add your handling code here:
    aCodCli = e.getActionCommand();
    System.out.println(aCodCli);
    aNome = e.getActionCommand();
    System.out.println(aNome);
    aFone = e.getActionCommand();
    System.out.println(aFone);
}
}

/**
*

  • @param args the command line arguments
    */
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new aClasse().setVisible(true);
    }
    });
    }

    // Variables declaration - do not modify
    private javax.swing.JButton BSair;
    private javax.swing.JTextField ECodCli;
    private javax.swing.JTextField EFone;
    private javax.swing.JTextField ENome;
    private javax.swing.JLabel LCodigo;
    private javax.swing.JLabel LFone;
    private javax.swing.JLabel LNome;
    // End of variables declaration

}

Está dando esse erro na linha em negrito quando é compilado: O que pode ser ?

D:\Teste\Java\Classes\pClasse\src\aClasse.java:91: ‘class’ or ‘interface’ expected

Nota: Só para lembrar, estou usando o NetBens 4.1 e o formulário junto com os TextFields, Botões foram inseridos
a partir da Paleta Swing.

Valeu.

Dá uma olhada no método acima do main, está sobrando “}”.

Dica: Sempre q vc ver algum erro maluco dá uma olhada no q vem antes. :wink: :wink: :wink:

aCodCli = e.getActionCommand();

Erro:

D:\Teste\Java\Classes\pClasse\src\aClasse.java:78: cannot find symbol

Não está encontrando o atributo “e”.

 private void ECodCliActionPerformed(java.awt.event.ActionEvent evt) {

Troca o ‘evt’ do método por ‘e’ q funfa

 private void ECodCliActionPerformed(java.awt.event.ActionEvent e) {

public class aClasse extends javax.swing.JFrame {

/** Creates new form aClasse */
private String aCodCli;
private String aNome;
private String aFone;

/** This method is called from within the constructor to
 * initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
private void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;

    LCodigo = new javax.swing.JLabel();
    LNome = new javax.swing.JLabel();
    LFone = new javax.swing.JLabel();
    ECodCli = new javax.swing.JTextField();
    ENome = new javax.swing.JTextField();
    EFone = new javax.swing.JTextField();
    BSair = new javax.swing.JButton();

    getContentPane().setLayout(null);

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("Formul\u00e1rio de teste");
    setName("FCadastro");
    LCodigo.setText("C\u00f3digo");
    getContentPane().add(LCodigo);
    LCodigo.setBounds(10, 10, 44, 15);

    LNome.setText("Nome");
    getContentPane().add(LNome);
    LNome.setBounds(10, 80, 37, 15);

    LFone.setText("Telefone");
    getContentPane().add(LFone);
    LFone.setBounds(10, 150, 60, 15);

    ECodCli.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            ECodCliActionPerformed(evt);
        }
    });

    getContentPane().add(ECodCli);
    ECodCli.setBounds(10, 30, 130, 20);

    getContentPane().add(ENome);
    ENome.setBounds(10, 100, 250, 20);

    getContentPane().add(EFone);
    EFone.setBounds(10, 170, 130, 20);

    BSair.setText("Sair");
    getContentPane().add(BSair);
    BSair.setBounds(340, 270, 57, 23);

    pack();
    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    java.awt.Dimension dialogSize = getSize();
    setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-dialogSize.height)/2);
}

private void ECodCliActionPerformed(java.awt.event.ActionEvent evt) {
    // TODO add your handling code here:
    aCodCli = evt.getActionCommand();
    System.out.println(aCodCli);
    aNome = evt.getActionCommand();
    System.out.println(aNome);
    aFone = evt.getActionCommand();
    System.out.println(aFone);
}

/**
*

  • @param args the command line arguments
    */
    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new aClasse().setVisible(true);
    }
    });

// aClasse jan=new aClasse();
// jan.setVisible(true);

}

// Variables declaration - do not modify
private javax.swing.JButton BSair;
private javax.swing.JTextField ECodCli;
private javax.swing.JTextField EFone;
private javax.swing.JTextField ENome;
private javax.swing.JLabel LCodigo;
private javax.swing.JLabel LFone;
private javax.swing.JLabel LNome;
// End of variables declaration

}

Corrigido os problemas de compilação, os componentes do form não aparecem.