Load the Jtextfield with a single Combobox

0

I have the following form and I need that when choosing the rut, dni from the combobox the data of said worker is loaded from the BD in the jtextfield (I am working from oracle express edition 11g) Any idea how to do it? would be a big help please ...

    
asked by Ivan Valverde 26.06.2017 в 00:43
source

1 answer

0

what development IDE are you using ?, in my case I use Eclipse IDE and I use to design in Swing, Windows Builder Editor. For what you want to do you must add an ItemListener so that when you change the value of your comboBoxRut you can make a Select to the table of your database and show the information in the jtextfield.

JComboBox comboBoxRut = new JComboBox(new Object[]{});
    comboBoxRut.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent arg0) {
           //En la variable arg0 se almacena el valor del Item seleccionado
           System.out.println("Combo"+ arg0.getItem());
           //haces un Select para buscar los datos a mostrar en los jtextfield
        }
    });

I ask you about the IDE because depending on what you use it makes it easier to add the ItemListener. Greetings and I hope it serves you.

    
answered by 26.06.2017 в 02:12