Tengo el siguiente problema, llamo al metodo mostrar_usu_rol(recibe 2 objetos) en el metodo btb_login,ambos metodos son de la clase Login_usuarios. El metodo mostrar_usu_rol debe mostrar el nombre y descripcion del rol de quien inicia sesion en el sistema, los datos se van a mostrar en el menu de adminis (se abre el nuevo frame del menu, cuando se inicia correctamente la sesion), el tema esta, en que, cuando se abre el frame de menu de adminis, no aparecen el nombre del usuario y su rol, ¿por qué no realiza su funcion el metodo mostrar_usu_rol, cuando lo llamo en el metodo btb_login?Desde ya agradeceria la ayuda;adjunto la imagen con el codigo.
Dejo el codigo mas abajo:
package Pantallas;
import Modelo.Rol_dto;
import Modelo.Usua_dao;
import Modelo.Usua_dto;
import Pantallas.Registro_nuev_usu;
import javax.swing.JOptionPane;
public class Login_usuarios extends javax.swing.JFrame {
public Login_usuarios() {
initComponents();
//Menú_adminis madmin=new Menú_adminis();
}
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
cont_panel = new javax.swing.JPanel();
btb_new_reg = new javax.swing.JButton();
btb_login = new javax.swing.JButton();
caja_passw = new javax.swing.JPasswordField();
caja_usua = new javax.swing.JTextField();
lbl_pass = new javax.swing.JLabel();
lbl_usua = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
btb_new_reg.setFont(new java.awt.Font("Trebuchet MS", 3, 14)); // NOI18N
btb_new_reg.setText("Nuevo registro");
btb_new_reg.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btb_new_regActionPerformed(evt);
}
});
btb_login.setFont(new java.awt.Font("Trebuchet MS", 3, 18)); // NOI18N
btb_login.setText("Loguearse");
btb_login.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btb_loginActionPerformed(evt);
}
});
caja_passw.setFont(new java.awt.Font("Sylfaen", 2, 14)); // NOI18N
caja_usua.setFont(new java.awt.Font("Sylfaen", 2, 14)); // NOI18N
lbl_pass.setFont(new java.awt.Font("Sylfaen", 2, 14)); // NOI18N
lbl_pass.setText("Password");
lbl_usua.setFont(new java.awt.Font("Sylfaen", 2, 14)); // NOI18N
lbl_usua.setText("Usuario");
javax.swing.GroupLayout cont_panelLayout = new javax.swing.GroupLayout(cont_panel);
cont_panel.setLayout(cont_panelLayout);
cont_panelLayout.setHorizontalGroup(
cont_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(cont_panelLayout.createSequentialGroup()
.addGroup(cont_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(cont_panelLayout.createSequentialGroup()
.addGap(43, 43, 43)
.addGroup(cont_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lbl_pass, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lbl_usua, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(84, 84, 84)
.addGroup(cont_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(caja_passw, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(caja_usua, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(cont_panelLayout.createSequentialGroup()
.addGap(137, 137, 137)
.addComponent(btb_login, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(112, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, cont_panelLayout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(btb_new_reg)
.addGap(24, 24, 24))
);
cont_panelLayout.setVerticalGroup(
cont_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(cont_panelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(cont_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lbl_usua, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(caja_usua, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(cont_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lbl_pass, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(caja_passw, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(39, 39, 39)
.addComponent(btb_login, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(15, 15, 15)
.addComponent(btb_new_reg, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(21, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(cont_panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap(28, Short.MAX_VALUE)
.addComponent(cont_panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
pack();
}// </editor-fold>
private void btb_loginActionPerformed(java.awt.event.ActionEvent evt) {
Usua_dao usudao=new Usua_dao();
Usua_dto usudto=new Usua_dto();
Rol_dto rdto=new Rol_dto();
Menú_adminis madmin=new Menú_adminis();
if(!caja_usua.getText().equals("")&&!caja_passw.getPassword().equals("")){
usudto.setUsuario_sistema(caja_usua.getText());
usudto.setPassword(String.valueOf(caja_passw.getPassword()));
if(usudao.Loguear(usudto, rdto)){
if(usudto.getId_rol()==1 && rdto.getDescripcion_rol().equals("administrador")){
dispose();
JOptionPane.showMessageDialog(null, "bienvenido al sistema Administrador");
madmin.setVisible(true);
**this.mostrar_usu_rol(usudto, rdto);**
>DEBERIA MOSTRAR EN EL FRAME madmin, el rol y
>> el usuario que ingreso al sistema en los labels
//madmin.rol_lbl.setText(rdto.getDescripcion_rol());
//madmin.usua_lbl.setText(usudto.getUsuario_sistema());
//JOptionPane.showMessageDialog(null, "el usuario" + " " + usudto.getUsuario_sistema()+ " " + "con el rol"+ " " + rdto.getDescripcion_rol()+ " " + "ha ingresado al sistema");
}else{
dispose();
JOptionPane.showMessageDialog(null, "bienvenido al sistema usuario invitado");
}
}else{
JOptionPane.showMessageDialog(null, "Los datos ingresados son incorrectos, verifique los datos que ingreso");
}
}
}
private void btb_new_regActionPerformed(java.awt.event.ActionEvent evt) {
Registro_nuev_usu reg_usu= new Registro_nuev_usu();
reg_usu.setVisible(true);
}
```public void mostrar_usu_rol(Usua_dto usudto, Rol_dto rdto){
Menú_adminis madmin=new Menú_adminis();
madmin.usua_lbl.setText(usudto.getUsuario_sistema());
madmin.rol_lbl.setText(rdto.getDescripcion_rol());
```
}> este es el metodo que no estaría cumpliendo su función,
>> cuando lo llamo en el metodo
>>> **btb_loginActionPerformed**
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Login_usuarios().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton btb_login;
private javax.swing.JButton btb_new_reg;
private javax.swing.JPasswordField caja_passw;
private javax.swing.JTextField caja_usua;
private javax.swing.JPanel cont_panel;
private javax.swing.JLabel lbl_pass;
private javax.swing.JLabel lbl_usua;
// End of variables declaration
}