java Swing, How to add a jcombobox to a jpanel by setting the grid bag distribution by code?

0

The idea would be that when I add the combo I also configure the regilla bag distribution giving the weight of x in 1 and the dey in 0 in the distribution of the Jpanel.

//El código sería  el siguiente
JComboBox cmbNomDocumentoJEP = new JComboBox();
jPanel17.add(cmbNomDocumentoJEP);
    
asked by Fabian Peñaloza 28.08.2018 в 15:21
source

1 answer

0

Greetings friends I found this solution and it worked well when I ran the screen. // here is added the regilla bag distribution with greater weight in X

   JComboBox cmbNomDocumentoJEP = new JComboBox();

    GridBagConstraints c = new GridBagConstraints();   
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.weighty = 0;

    jPanel17.add(cmbNomDocumentoJEP, c);
    
answered by 28.08.2018 в 16:24