eberson_oliveira , puts cara foi mal, acabei postando o OuvinteTelaDeLogin
ai vai a classe TelaDeLogin:
package co.departamentodetransito.visao;
import co.departamentodetransito.modelo.UsuarioVO;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
public class TelaDeLogin extends javax.swing.JFrame {
TelaPrincipal telaPrincipal = null;
// Construtor da Classe TelaDeLogin
public TelaDeLogin() {
initComponents();
lUsuarioLogin.setVisible(false);
lSenhaLogin.setVisible(false);
}
//Define um objeto do tipo TelaPrincipal nessa classe
public void setTelaIPrincipal(TelaPrincipal telaPrincipal) {
this.telaPrincipal = telaPrincipal;
}
//Define o OuvinteLogin
public void setOuvinteLogin( ActionListener OuvinteTelaDeLogin ) {
this.bEntrar.addActionListener(OuvinteTelaDeLogin);
}
//Obtém os dados de acesso do usuário
public UsuarioVO getUsuario() {
UsuarioVO usuario = new UsuarioVO();
usuario.setUsuario( this.tfUsuario.getText() );
usuario.setSenha( this.pfSenha.getText() );
return usuario;
}
//Defini se o login e a senha informado esta válida
public void setPesquisaLogin(String usuarioValido) {
if(!usuarioValido.isEmpty()) {
this.telaPrincipal.setUsuarioAtual(usuarioValido);
this.telaPrincipal.setLocationRelativeTo(null);
this.telaPrincipal.setVisible(true);
this.dispose();
}
else {
JOptionPane.showMessageDialog(this, "Usuário ou senha inválidos");
}
}
//Obtém as credenciais da interface
public void setOuvintePesquisar( ActionListener ouvinte) {
// this.bEntrar.addActionListener(ouvinte);
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel11 = new javax.swing.JPanel();
pFundo = new javax.swing.JPanel();
jPanel10 = new javax.swing.JPanel();
jLabel21 = new javax.swing.JLabel();
jLabel22 = new javax.swing.JLabel();
tfUsuario = new javax.swing.JTextField();
jLabel23 = new javax.swing.JLabel();
jLabel24 = new javax.swing.JLabel();
bEntrar = new javax.swing.JButton();
pfSenha = new javax.swing.JPasswordField();
jButton_solicitarNovaSenha = new javax.swing.JButton();
lUsuarioLogin = new javax.swing.JLabel();
lSenhaLogin = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
bSair = new javax.swing.JButton();
bMinimizar = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Sistema se Gerenciamento do Transporte Nacional");
setResizable(false);
setUndecorated(true);
jPanel11.setBackground(new java.awt.Color(172, 172, 255));
jPanel11.setBorder(javax.swing.BorderFactory.createEtchedBorder(new java.awt.Color(204, 204, 204), new java.awt.Color(0, 51, 51)));
jPanel11.setMinimumSize(new java.awt.Dimension(63, 866));
jPanel11.setPreferredSize(new java.awt.Dimension(866, 63));
pFundo.setBackground(new java.awt.Color(255, 255, 255));
pFundo.addAncestorListener(new javax.swing.event.AncestorListener() {
public void ancestorMoved(javax.swing.event.AncestorEvent evt) {
}
public void ancestorAdded(javax.swing.event.AncestorEvent evt) {
pFundoAncestorAdded(evt);
}
public void ancestorRemoved(javax.swing.event.AncestorEvent evt) {
}
});
jPanel10.setBackground(new java.awt.Color(152, 152, 255));
jPanel10.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, new java.awt.Color(0, 51, 51), new java.awt.Color(204, 204, 204), new java.awt.Color(0, 51, 51), new java.awt.Color(204, 204, 204)));
jPanel10.setMinimumSize(new java.awt.Dimension(300, 357));
jLabel21.setFont(new java.awt.Font("Verdana", 0, 15));
jLabel21.setText("Usuário");
jLabel21.setAlignmentX(0.5F);
jLabel22.setFont(new java.awt.Font("Verdana", 0, 15));
jLabel22.setText("Senha");
tfUsuario.setFont(new java.awt.Font("Verdana", 0, 14));
tfUsuario.setBorder(javax.swing.BorderFactory.createEtchedBorder(java.awt.Color.lightGray, new java.awt.Color(0, 51, 51)));
jLabel23.setFont(new java.awt.Font("Tahoma", 1, 12));
jLabel23.setForeground(new java.awt.Color(0, 51, 51));
jLabel23.setText("Entre no SDT com seu usuário e senha.");
jLabel24.setFont(new java.awt.Font("Lucida Grande", 0, 8));
jLabel24.setText("Exemplo: fulanobeltrano");
jLabel24.setAlignmentX(0.5F);
bEntrar.setFont(new java.awt.Font("Arial", 0, 15));
bEntrar.setText("Entrar");
bEntrar.setBorder(javax.swing.BorderFactory.createEtchedBorder(java.awt.Color.lightGray, new java.awt.Color(0, 51, 51)));
bEntrar.setPreferredSize(new java.awt.Dimension(73, 21));
bEntrar.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
bEntrarjButton_EntrarMouseClicked(evt);
}
public void mouseEntered(java.awt.event.MouseEvent evt) {
bEntrarMouseEntered(evt);
}
public void mouseExited(java.awt.event.MouseEvent evt) {
bEntrarMouseExited(evt);
}
});
pfSenha.setFont(new java.awt.Font("Verdana", 0, 14));
pfSenha.setBorder(javax.swing.BorderFactory.createEtchedBorder(new java.awt.Color(204, 204, 204), new java.awt.Color(0, 51, 51)));
jButton_solicitarNovaSenha.setText("Não consigo acessar minha conta");
jButton_solicitarNovaSenha.setBorder(javax.swing.BorderFactory.createEtchedBorder(java.awt.Color.lightGray, new java.awt.Color(0, 51, 51)));
jButton_solicitarNovaSenha.setPreferredSize(new java.awt.Dimension(163, 21));
jButton_solicitarNovaSenha.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton_solicitarNovaSenhajButton_solicitarNovaSenhaMouseClicked(evt);
}
public void mouseEntered(java.awt.event.MouseEvent evt) {
jButton_solicitarNovaSenhaMouseEntered(evt);
}
public void mouseExited(java.awt.event.MouseEvent evt) {
jButton_solicitarNovaSenhaMouseExited(evt);
}
});
lUsuarioLogin.setFont(new java.awt.Font("Tahoma", 1, 11));
lUsuarioLogin.setForeground(new java.awt.Color(255, 0, 0));
lUsuarioLogin.setText("Campo obrigatório");
lSenhaLogin.setFont(new java.awt.Font("Tahoma", 1, 11));
lSenhaLogin.setForeground(new java.awt.Color(255, 0, 0));
lSenhaLogin.setText("Campo obrigatório");
org.jdesktop.layout.GroupLayout jPanel10Layout = new org.jdesktop.layout.GroupLayout(jPanel10);
jPanel10.setLayout(jPanel10Layout);
jPanel10Layout.setHorizontalGroup(
jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel10Layout.createSequentialGroup()
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel23)
.add(jButton_solicitarNovaSenha, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 240, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(jLabel21)
.add(jPanel10Layout.createSequentialGroup()
.add(tfUsuario, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 159, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(lUsuarioLogin))
.add(jLabel24)
.add(jLabel22)
.add(jPanel10Layout.createSequentialGroup()
.add(pfSenha, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 167, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(lSenhaLogin))
.add(bEntrar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.add(26, 26, 26))
);
jPanel10Layout.setVerticalGroup(
jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel10Layout.createSequentialGroup()
.add(jLabel23)
.add(18, 18, 18)
.add(jLabel21, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 22, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(tfUsuario, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 25, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(lUsuarioLogin))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jLabel24)
.add(23, 23, 23)
.add(jLabel22)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(pfSenha, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 25, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(lSenhaLogin))
.add(18, 18, 18)
.add(bEntrar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(18, 18, 18)
.add(jButton_solicitarNovaSenha, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 21, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(31, Short.MAX_VALUE))
);
jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/co/departamentodetransito/visao/transito.gif"))); // NOI18N
org.jdesktop.layout.GroupLayout pFundoLayout = new org.jdesktop.layout.GroupLayout(pFundo);
pFundo.setLayout(pFundoLayout);
pFundoLayout.setHorizontalGroup(
pFundoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, pFundoLayout.createSequentialGroup()
.add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 406, Short.MAX_VALUE)
.add(5, 5, 5)
.add(jPanel10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 298, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
pFundoLayout.setVerticalGroup(
pFundoLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(pFundoLayout.createSequentialGroup()
.addContainerGap()
.add(jPanel10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 289, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 311, Short.MAX_VALUE)
);
bSair.setBackground(new java.awt.Color(172, 172, 255));
bSair.setFont(new java.awt.Font("Verdana", 1, 12));
bSair.setText("X");
bSair.setBorder(null);
bSair.setBorderPainted(false);
bSair.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
bSairMouseClicked(evt);
}
public void mouseEntered(java.awt.event.MouseEvent evt) {
bSairMouseEntered(evt);
}
public void mouseExited(java.awt.event.MouseEvent evt) {
bSairMouseExited(evt);
}
});
bMinimizar.setBackground(new java.awt.Color(172, 172, 255));
bMinimizar.setFont(new java.awt.Font("Verdana", 1, 19));
bMinimizar.setText("-");
bMinimizar.setBorder(null);
bMinimizar.setBorderPainted(false);
bMinimizar.setPreferredSize(new java.awt.Dimension(9, 17));
bMinimizar.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
bMinimizarMouseClicked(evt);
}
public void mouseEntered(java.awt.event.MouseEvent evt) {
bMinimizarMouseEntered(evt);
}
public void mouseExited(java.awt.event.MouseEvent evt) {
bMinimizarMouseExited(evt);
}
});
org.jdesktop.layout.GroupLayout jPanel11Layout = new org.jdesktop.layout.GroupLayout(jPanel11);
jPanel11.setLayout(jPanel11Layout);
jPanel11Layout.setHorizontalGroup(
jPanel11Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel11Layout.createSequentialGroup()
.addContainerGap(679, Short.MAX_VALUE)
.add(bMinimizar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 17, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(1, 1, 1)
.add(bSair, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 17, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.add(jPanel11Layout.createSequentialGroup()
.add(pFundo, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(0, 0, 0))
);
jPanel11Layout.setVerticalGroup(
jPanel11Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel11Layout.createSequentialGroup()
.add(jPanel11Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(bMinimizar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(bSair))
.add(30, 30, 30)
.add(pFundo, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(60, 60, 60))
);
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel11, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 728, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jPanel11, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 421, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
private void bEntrarjButton_EntrarMouseClicked(java.awt.event.MouseEvent evt) {
}
private void jButton_solicitarNovaSenhajButton_solicitarNovaSenhaMouseClicked(java.awt.event.MouseEvent evt) {
this.tfUsuario.setText("");
this.pfSenha.setText("");
TelaSolicitarNovaSenha telaSolicitarNovaSenha = new TelaSolicitarNovaSenha(this, true);
telaSolicitarNovaSenha.setLocationRelativeTo(null);
telaSolicitarNovaSenha.setVisible(true);
OuvinteTelaSolicitarNovaSenha ouvinteTelaSolicitarNovaSenha = new OuvinteTelaSolicitarNovaSenha(telaSolicitarNovaSenha);
}
private void bSairMouseEntered(java.awt.event.MouseEvent evt) {
bSair.setForeground(new java.awt.Color(255, 102, 0));
}
private void bSairMouseExited(java.awt.event.MouseEvent evt) {
bSair.setForeground(new java.awt.Color(0,0,0));
}
private void bMinimizarMouseEntered(java.awt.event.MouseEvent evt) {
bMinimizar.setForeground(new java.awt.Color(255, 102, 0));
}
private void bMinimizarMouseExited(java.awt.event.MouseEvent evt) {
bMinimizar.setForeground(new java.awt.Color(0,0,0));
}
private void bSairMouseClicked(java.awt.event.MouseEvent evt) {
System.exit(0);
}
private void bMinimizarMouseClicked(java.awt.event.MouseEvent evt) {
this.setExtendedState(TelaDeLogin.ICONIFIED);
}
private void pFundoAncestorAdded(javax.swing.event.AncestorEvent evt) {
}
private void bEntrarMouseEntered(java.awt.event.MouseEvent evt) {
bEntrar.setBorder(javax.swing.BorderFactory.createEtchedBorder(java.awt.Color.orange, new java.awt.Color(0, 51, 51)));
}
private void bEntrarMouseExited(java.awt.event.MouseEvent evt) {
bEntrar.setBorder(javax.swing.BorderFactory.createEtchedBorder(java.awt.Color.LIGHT_GRAY, new java.awt.Color(0, 51, 51)));
}
private void jButton_solicitarNovaSenhaMouseEntered(java.awt.event.MouseEvent evt) {
jButton_solicitarNovaSenha.setBorder(javax.swing.BorderFactory.createEtchedBorder(java.awt.Color.orange, new java.awt.Color(0, 51, 51)));
}
private void jButton_solicitarNovaSenhaMouseExited(java.awt.event.MouseEvent evt) {
jButton_solicitarNovaSenha.setBorder(javax.swing.BorderFactory.createEtchedBorder(java.awt.Color.LIGHT_GRAY, new java.awt.Color(0, 51, 51)));
}
// Variables declaration - do not modify
private javax.swing.JButton bEntrar;
private javax.swing.JButton bMinimizar;
private javax.swing.JButton bSair;
private javax.swing.JButton jButton_solicitarNovaSenha;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel21;
private javax.swing.JLabel jLabel22;
private javax.swing.JLabel jLabel23;
private javax.swing.JLabel jLabel24;
private javax.swing.JPanel jPanel10;
private javax.swing.JPanel jPanel11;
private javax.swing.JLabel lSenhaLogin;
private javax.swing.JLabel lUsuarioLogin;
private javax.swing.JPanel pFundo;
private javax.swing.JPasswordField pfSenha;
private javax.swing.JTextField tfUsuario;
// End of variables declaration
}