Problema ao fechar

posta o código pra gente dar uma olhada… fica mais fácil

Ola…
coloca isso no frame que vc quer que não feche pelo x.

suajanela.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

desta forma quando o usuario clicar no x do frame, nada acontecerá…
vc pode usar um JInternalFrame e retirar o x do Frame também.

Tou com problema tenho um a tela de login quando aperto no X na barra de titulo ele abre o sistema como faço qdo aperto X feche, quero somente qdo dar login!!!

/*
 * FormLogin.java
 *
 * Created on 2 de Agosto de 2006, 09:06
 */

package br.com.cadastro.forms;

import br.com.cadastro.beans.Usuario;
import br.com.cadastro.controlador.UsuarioControlador;
import com.jgoodies.looks.plastic.PlasticXPLookAndFeel;
import java.awt.event.KeyEvent;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;


public class FormLogin extends javax.swing.JDialog {
    
    /** Creates new form FormLogin */
    public FormLogin(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        try {
            UIManager.setLookAndFeel(new PlasticXPLookAndFeel());
             SwingUtilities.updateComponentTreeUI(this);
        } catch (UnsupportedLookAndFeelException e) {
          
        }
        setLocationRelativeTo(null);
    }
    
   
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                          
    private void initComponents() {
        jLabel1 = new javax.swing.JLabel();
        SenhaProg = new javax.swing.JPasswordField();
        jLabel2 = new javax.swing.JLabel();
        UsuaProg = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        EmpProg = new javax.swing.JComboBox();
        BtnEntrar = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        jLabel1.setText("Usu\u00e1rio");

        SenhaProg.setPreferredSize(new java.awt.Dimension(131, 24));
        SenhaProg.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                SenhaProgKeyPressed(evt);
            }
        });

        jLabel2.setText("Senha");

        UsuaProg.setPreferredSize(new java.awt.Dimension(121, 24));

        jLabel3.setText("Empresa");

        EmpProg.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "INTERSIG" }));
        EmpProg.setPreferredSize(new java.awt.Dimension(121, 24));

        BtnEntrar.setText("Entrar");
        BtnEntrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BtnEntrarActionPerformed(evt);
            }
        });

        jButton1.setText("Cancelar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .addContainerGap()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                            .add(SenhaProg, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(jLabel2)
                            .add(UsuaProg, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(jLabel1)
                            .add(jLabel3)
                            .add(EmpProg, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 242, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                    .add(layout.createSequentialGroup()
                        .add(45, 45, 45)
                        .add(BtnEntrar)
                        .add(17, 17, 17)
                        .add(jButton1)))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jLabel3)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(EmpProg, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(9, 9, 9)
                .add(jLabel1)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(UsuaProg, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jLabel2)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(SenhaProg, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(28, 28, 28)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(BtnEntrar)
                    .add(jButton1))
                .addContainerGap(31, Short.MAX_VALUE))
        );
        pack();
    }// </editor-fold>                        

    private void SenhaProgKeyPressed(java.awt.event.KeyEvent evt) {                                     
int key = evt.getKeyCode();
            if(key == KeyEvent.VK_ENTER) {
     if(UsuaProg.getText().length() == 0 && SenhaProg.getPassword().length == 0) {
            JOptionPane.showMessageDialog(null, "Informe usuário e senha.", "ATENÇÃO...", JOptionPane.ERROR_MESSAGE);
        } else {
            
            Usuario u = new Usuario();
            u.setEmpresa((String)EmpProg.getSelectedItem());
            u.setNomeUsuario(UsuaProg.getText());
            
            char[] senha = SenhaProg.getPassword();
            String senhaUsuario = "";
            for(int i = 0; i < senha.length; i++) {
                senhaUsuario += senha[i];
            }
            
            u.setSenha(senhaUsuario);
            
            //JOptionPane.showMessageDialog(null, u.getEmpresa() + " - " + u.getNomeUsuario() + " - " + u.getSenha(), "ATENÇÃO...", JOptionPane.ERROR_MESSAGE);
            
            u = UsuarioControlador.listar(u);
            
            if(u != null) {
        //        JOptionPane.showMessageDialog(null, "Usuário OK.", "ATENÇÃO...", JOptionPane.INFORMATION_MESSAGE);
                this.setVisible(false);
                this.dispose();
            } else {
                JOptionPane.showMessageDialog(null, "Usuário não encontrado.", "ATENÇÃO...", JOptionPane.ERROR_MESSAGE);
            }
        }
        
            }
    }                                    

    private void BtnEntrarActionPerformed(java.awt.event.ActionEvent evt) {                                          
  
        if(UsuaProg.getText().length() == 0 && SenhaProg.getPassword().length == 0) {
            JOptionPane.showMessageDialog(null, "Informe usuário e senha.", "ATENÇÃO...", JOptionPane.ERROR_MESSAGE);
        } else {
            
            Usuario u = new Usuario();
            u.setEmpresa((String)EmpProg.getSelectedItem());
            u.setNomeUsuario(UsuaProg.getText());
            
            char[] senha = SenhaProg.getPassword();
            String senhaUsuario = "";
            for(int i = 0; i < senha.length; i++) {
                senhaUsuario += senha[i];
            }
            
            u.setSenha(senhaUsuario);
            
            //JOptionPane.showMessageDialog(null, u.getEmpresa() + " - " + u.getNomeUsuario() + " - " + u.getSenha(), "ATENÇÃO...", JOptionPane.ERROR_MESSAGE);
            
            u = UsuarioControlador.listar(u);
            
            if(u != null) {
        //        JOptionPane.showMessageDialog(null, "Usuário OK.", "ATENÇÃO...", JOptionPane.INFORMATION_MESSAGE);
                this.setVisible(false);
                this.dispose();
            } else {
                JOptionPane.showMessageDialog(null, "Usuário não encontrado.", "ATENÇÃO...", JOptionPane.ERROR_MESSAGE);
            }
        }
        
    }                                         

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
        System.exit(0);
    }                                        
    
    
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new FormLogin(new javax.swing.JFrame(), true).setVisible(true);
            }
        });
    }
    
    // Variables declaration - do not modify                     
    private javax.swing.JButton BtnEntrar;
    private javax.swing.JComboBox EmpProg;
    private javax.swing.JPasswordField SenhaProg;
    private javax.swing.JTextField UsuaProg;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    // End of variables declaration                   
    
}