I can not Establish Focus A Java SE Form

0

Thanks for the help I have a form in java to open it I assigned the focus to the first jtextfield, I tried with requestfocus () after initComponents (); but nothing always opens the focus in the first jtextfield I also read that grabfocus and nothing like change the order that gives netbeans to the jtextfield he assigns them according to his creation and I want him to start with focus in the fifth jtextfiel thank you very much

I put the beginning because I did not reach everything by limitation characters

public class Invoice extends javax.swing.JInternalFrame {

private Control ctrl;
/////instanciar fefcha
Calendar c1 = Calendar.getInstance();
Calendar c2 = new GregorianCalendar();
String dia;
String mes;
String annio;
DefaultTableModel ingresar;
/** Creates new form Factura */

// @SuppressWarnings ("unchecked")     Public Invoice (Control ctrl) {

    dia = Integer.toString(c2.get(Calendar.DATE));
    mes = Integer.toString(c2.get(Calendar.MONTH)+1);
    annio = Integer.toString(c2.get(Calendar.YEAR));

    initComponents();
    Dimension tamFrame=this.getSize();
    Dimension tamPantalla=Toolkit.getDefaultToolkit().getScreenSize(); 
    setLocation((tamPantalla.width-tamFrame.width)/2, (tamPantalla.height-tamFrame.height)/12);
    this.ctrl = ctrl;
    this.setTitle("Registro de Ventas ");
    //Se obtiene el nombre del cliente
    txtName.setText( ctrl.getNameCliente() );
    ID.setText( ctrl.getIdCliente() );
     //vis.setVisible(false);
    salir.setVisible(false);

    //se genera un codigo Random para Numero de factura
    txtNumFactura.setText( ctrl.GenerarNumFactura() );
    txtVendedor.getText();   

     Date fechaActual = new Date();
     DateFormat formatoFecha = new SimpleDateFormat("yyyy-MM-dd");
     String fechast = formatoFecha.format(fechaActual);
     txtFecha.setText( fechast );

    btnUpObs.setVisible(false);


  ////////// Completar Codigo
TextAutoCompleter textAutoCompleter = new TextAutoCompleter(codigob);
String sql="";
sql="SELECT * FROM producto ";
String []datos = new String [1];
 try {
        Statement st = cn.createStatement();
        ResultSet rs = st.executeQuery(sql);
        while(rs.next()){
            datos[0]=rs.getString(1);
            textAutoCompleter.addItem(datos[0]=rs.getString(1));
        }

    } catch (SQLException ex) {
        Logger.getLogger(ingresoproductos.class.getName()).log(Level.SEVERE, null, ex);
    }


    /////////  Completar Nombre
 TextAutoCompleter Nombre = new TextAutoCompleter(pName);
String sqln="";
sqln="SELECT * FROM producto ";
String []datosn = new String [2];
 try {
        Statement stn = cn.createStatement();
        ResultSet rsn = stn.executeQuery(sql);
        while(rsn.next()){
            datosn[1]=rsn.getString(2);
            Nombre.addItem(datosn[1]=rsn.getString(2));
        }

    } catch (SQLException ex) {
        Logger.getLogger(ingresoproductos.class.getName()).log(Level.SEVERE, null, ex);
    }  


}
    
asked by Jesus Antonio Sanchez Sanchez 29.04.2018 в 18:29
source

0 answers