Duvida na compilacao

3 respostas
Z

Quando compilo algumas classes em java, ao invés de gerar somente um arquivo .class, é gerado mais de um.

Por exemplo:

javac telalogin.java

gera:

telalogin.class
telalogin$1.class
telalogin$2.class

Alguém saberia dizer porque ?

[]s
Zeus

3 Respostas

C

pq vc tem a declaração de outra classe dentro da sua classe principal:

public class Princ
{
  private class Interna
  {
  }
}
Z

Mas eu só tenho uma. Olhe o programa:

import javax.swing.JFrame;

import javax.swing.JComboBox;

import javax.swing.JTextField;

import javax.swing.JPasswordField;

import javax.swing.JButton;

import javax.swing.JLabel;

/*
  • Created on 19/08/2004
  • TODO To change the template for this generated file go to
  • Window - Preferences - Java - Code Style - Code Templates
    */

/**

  • @author Zeus

  • TODO To change the template for this generated type comment go to

  • Window - Preferences - Java - Code Style - Code Templates
    */
    public class telalogin extends JFrame {

    private javax.swing.JPanel jContentPane = null;

    private JComboBox jCBtitular;
    
    private JTextField jTFagencia = null;
    
    private JPasswordField jTFsenha = null;
    
    private JButton jBentrar = null;
    
    private JButton jBLimpa = null;
    
    private JTextField jTFconta = null;
    
    private JLabel jLtitular = null;
    
    private JLabel jLagencia = null;
    
    private JLabel jLconta = null;
    
    private JLabel jLsenha = null;
    
    /**
    
    • This method initializes jComboBox

    • @return javax.swing.JComboBox	
      
      */
      
      private JComboBox getJCBtitular() {
      
      if (jCBtitular == null) {
      
      jCBtitular = new JComboBox();
      
      jCBtitular.addItem(1º Titular);
      
      jCBtitular.addItem(2º Titular);
      
      jCBtitular.addItem(3º Titular);
      
      jCBtitular.addItem(4º Titular);
      
      jCBtitular.setBounds(43, 26, 175, 20);
      
      jCBtitular.addItemListener(new java.awt.event.ItemListener() { 
       	public void itemStateChanged(java.awt.event.ItemEvent e) {    
       	}
       });
      
      }
      
      return jCBtitular;
      
      }
      
      /**
      
    • This method initializes jTextField

    • @return javax.swing.JTextField	
      
      <em>/
      
      private JTextField getJTFagencia() {
      
      if (jTFagencia == null) {
      
      jTFagencia = new JTextField();
      
      jTFagencia.setBounds(43, 78, 108, 20);
      
      }
      
      return jTFagencia;
      
      }
      
      /</em>*
      
    • This method initializes jPasswordField

    • @return javax.swing.JPasswordField	
      
      <em>/
      
      private JPasswordField getJTFsenha() {
      
      if (jTFsenha == null) {
      
      jTFsenha = new JPasswordField();
      
      jTFsenha.setBounds(43, 135, 108, 20);
      
      jTFsenha.setEchoChar(’$’);
      
      }
      
      return jTFsenha;
      
      }
      
      /</em>*
      
    • This method initializes jButton

    • @return javax.swing.JButton	
      
      <em>/
      
      private JButton getJBentrar() {
      
      if (jBentrar == null) {
      
      jBentrar = new JButton();
      
      jBentrar.setBounds(56, 173, 85, 32);
      
      jBentrar.setText(Entrar);
      
      jBentrar.setMnemonic(java.awt.event.KeyEvent.VK_E);
      
      jBentrar.addActionListener(new java.awt.event.ActionListener() {
      
      public void actionPerformed(java.awt.event.ActionEvent e) {
      
      System.out.println(jCBtitular.getSelectedItem()); // TODO Auto-generated Event stub itemStateChanged()
      
      // TODO Auto-generated Event stub actionPerformed()
      
      }
      
      });
      
      }
      
      return jBentrar;
      
      }
      
      /</em>*
      
    • This method initializes jButton

    • @return javax.swing.JButton	
      
      <em>/
      
      private JButton getJBLimpa() {
      
      if (jBLimpa == null) {
      
      jBLimpa = new JButton();
      
      jBLimpa.setBounds(197, 173, 85, 32);
      
      jBLimpa.setText(“Limpar”);
      
      }
      
      return jBLimpa;
      
      }
      
      /</em>*
      
    • This method initializes jTextField

    • @return javax.swing.JTextField	
      
      */
      
      private JTextField getJTFconta() {
      
      if (jTFconta == null) {
      
      jTFconta = new JTextField();
      
      jTFconta.setBounds(194, 79, 102, 20);
      
      }
      
      return jTFconta;
      
      }
      
      public static void main(String[] args) {
      
      telalogin lab01  = new telalogin();
      
      lab01.setDefaultCloseOperation(EXIT_ON_CLOSE);
      
      lab01.setVisible(true);
      

    }
    /**

    • This is the default constructor
      
      */
      
      public telalogin() {
      
      super();
      
      initialize();
      
      }
      
      /**
      
    • This method initializes this

    • @return void
      
      <em>/
      
      private void initialize() {
      
      this.setTitle("Banco Ilhas Caymas ");
      
      this.setContentPane(getJContentPane());
      
      this.setSize(347, 263);
      
      }
      
      /</em>*
      
    • This method initializes jContentPane

    • @return javax.swing.JPanel
      
      */
      
      private javax.swing.JPanel getJContentPane() {
      
      if(jContentPane == null) {
      
      jLtitular = new JLabel();
      
      jLconta = new JLabel();
      
      jLconta = new JLabel();
      
      jLagencia = new JLabel();
      
      jLsenha = new JLabel();
      
      jContentPane = new javax.swing.JPanel();
      
      jContentPane.setLayout(null);
      
      jLtitular.setBounds(43, 6, 63, 18);
      
      jLtitular.setText(Titular);
      
      jLagencia.setBounds(44, 57, 62, 18);
      
      jLagencia.setText(Agência);
      
      jLconta.setBounds(194, 55, 54, 18);
      
      jLconta.setText(conta);
      
      jLsenha.setBounds(43, 114, 51, 18);
      
      jLsenha.setText(Senha);
      
      jContentPane.add(jLsenha, null);
      
      jLconta.setBounds(199, 67, 39, 10);
      
      jLconta.setText(Conta);
      
      jContentPane.add(jLagencia, null);
      
      jContentPane.add(jLconta, null);
      
      jContentPane.add(jLconta, null);
      
      jContentPane.add(getJCBtitular(), null);
      
      jContentPane.add(jLtitular, null);
      
      jContentPane.add(getJTFagencia(), null);
      
      jContentPane.add(getJTFsenha(), null);
      
      jContentPane.add(getJBentrar(), null);
      
      jContentPane.add(getJBLimpa(), null);
      
      jContentPane.add(getJTFconta(), null);
      
      }
      
      return jContentPane;
      
      }
      
      }  //  @jve:decl-index=0:visual-constraint=42,78
      
TedLoprao

Vc tem três…

Olhe o código:

jCBtitular.addItemListener(new java.awt.event.ItemListener() { 
public void itemStateChanged(java.awt.event.ItemEvent e) { 
} 
});

e

jBentrar.addActionListener(new java.awt.event.ActionListener() { 
public void actionPerformed(java.awt.event.ActionEvent e) { 
System.out.println(jCBtitular.getSelectedItem()); // TODO Auto-generated Event stub itemStateChanged() 
// TODO Auto-generated Event stub actionPerformed() 
} 
});

Essas são chamadas classes anônimas…

Fallow

Criado 20 de agosto de 2004
Ultima resposta 20 de ago. de 2004
Respostas 3
Participantes 3