modify jlabel according to user logged in java

3

I need to modify a Jlabel of the main page according to the user that has logged in in the Login Frame.

I leave the code that I am working on, in case you can help me. I remain attentive to your answers

  void generarNombre() {

    String sql = "Select CONCAT(nombre_usuario, ' ', apellido_usuario) As Nombre From usuarios;";
    conectar cc = new conectar();
    //    Connection cn = (Connection) cc.conexion();
    try {
        java.sql.Statement st = cn.createStatement();
        ResultSet rs = st.executeQuery(sql);
        while (rs.next()) {
            //Aca le digo que muestre el valor en un JtextFiel

            lb_usuario_recepcionista.setText(rs.getString("Nombre"));

        }

    } catch (SQLException e) {
        // NOTA: So hubo error muestra el error
        JOptionPane.showMessageDialog(null, e);
    }
}
    
asked by Juan Pablo 21.08.2018 в 20:08
source

1 answer

2

If you get the value you can subsequently refresh / repaint a value in your JLabel using the repaint() method.

   ... 
   while (rs.next()) {
        //Aca le digo que muestre el valor en un JtextFiel
        lb_usuario_recepcionista.setText(rs.getString("Nombre"));
    }
   lb_usuario_recepcionista.repaint();
   ...
    
answered by 21.08.2018 в 23:49