Formulário

14 respostas
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 = 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.

14 Respostas

B

Aconselho a vc deletar tudo isso:

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new aClasse().setVisible(true);

}

});

e substituir por:

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

Acho que vai funcionar sim, qualquer coisa é só me responder postando de volta , falo amigo.

E

aCodCli = e.getActionCommand();

Erro:

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

B

excon, eu não sei programar com NetBeans, só na unha, posso alterar o código do jeito que eu sei e te mandar de volta?

E

Claro que pode sinta-se a vontade como estou aprendendo vale a pena estuda tudo que estiver ao alcance.

Se quizer, pode enviar para:

[email removido] ou
[email removido] ou
[email removido]

Valeu.

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.

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.

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.

B

Já resolveu Gilberto?Eu consegui, mas só naum estou com o arquivo aki comigo, vou te mandar depois, caso não conseguiu ainda…

E

Olá;

Ainda não conseguí se quizer me enviar agradeço.

[email removido], [email removido] ou [email removido]

Valeu.

B

blz , mas vou enviar pro próprio portal, tá? pra ficar no fórum…
Estou na faculdade ,o PC ta sem JAVA e to sem o arquivo aki, por isso ainda naum mandei…

E

OK. Sem problemas estou aguardando.

Obrigado.

B

import javax.swing.;
import java.awt.
;

public class aClasse extends JFrame
{

/** Creates new form aClasse */

private String aCodCli;

private String aNome;

private String aFone;
// Variables declaration - do not modify

private JButton BSair;

private JTextField ECodCli;

private JTextField EFone;

private JTextField ENome;

private JLabel LCodigo;

private JLabel LFone;

private JLabel LNome;

/** 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 mostra() {
    //java.awt.GridBagConstraints gridBagConstraints;

// End of variables declaration

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();

this.getContentPane().setLayout(null);

this.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

this.setTitle(Formul\u00e1rio de teste);

this.setName(FCadastro);

LCodigo.setText(C\u00f3digo);

this.getContentPane().add(LCodigo);

LCodigo.setBounds(10, 10, 44, 15);
LNome.setText(Nome);

this.getContentPane().add(LNome);

LNome.setBounds(10, 80, 37, 15);
LFone.setText(Telefone);

this.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);

}

});

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

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

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

BSair.setText(Sair);

this.getContentPane().add(BSair);

BSair.setBounds(340, 270, 57, 23);
//pack();

java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();

java.awt.Dimension dialogSize = getSize();

this.setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-dialogSize.height)/2);

this.setSize(500,400);

this.setVisible(true);

}
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)
    {
    aClasse jan=new aClasse();
    jan.mostra();
    }

Qualquer coisa é só me falar , falo excon.

E

OK. Valeu

B

conseguiu?

Criado 4 de fevereiro de 2005
Ultima resposta 13 de fev. de 2005
Respostas 14
Participantes 2