Good was doing a little exercise: I wanted to press the button to save the info in the combo box, but I can not make it work, I tried different ways to save inside an arrangement to store the info and then show it in the combo box.
String[] v_arreglo = new String[5];
JLabel v_label2 = new JLabel();
v_label2.setText("Digite los datos: ");
v_label2.setVisible(true);
v_label2.setLocation(20, 50); //cuando no se muestra
v_label2.setSize(200, 20);
v_frame.add(v_label2);
JTextField v_nombre2 = new JTextField();
v_nombre2.setBounds(200, 50, 200, 20);
v_nombre2.setVisible(true);
v_frame.add(v_nombre2);
v_frame.setVisible(true);
JComboBox v_combo1 = new JComboBox(v_arreglo);
v_combo1.setBounds(190, 200, 120, 50);
v_combo1.setVisible(true);
v_combo1.setEnabled(true);
v_frame.add(v_combo1);
JButton v_boton2 = new JButton();
v_boton2.setText("Almacenar");
v_boton2.setBounds(150, 70, 100, 70);
v_boton2.setVisible(true);
v_frame.add(v_boton2);
v_boton2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
for (int i = 0; i < v_arreglo.length; i++) {
v_arreglo[0] = v_nombre.getText();
v_combo.addItem(v_arreglo[i]);
}
}
});
v_frame.repaint();
v_frame.setVisible(true);
}
I appreciate the assistance.