On the form I have two elements jList and ComboBox that receive information from SQLite database. When I start the program, I get an empty jList , although in the ComboBox value of the first table from the jList selected, but when switching between tables, the program supplements jList elements from the selected table. And you need the program to change the contents of jList in accordance with the table selected from jComboBox .
public Connection c=null; public DefaultComboBoxModel dcb = new DefaultComboBoxModel(); public DefaultListModel dlm = new DefaultListModel(); public void LoadList(){ // Запись из бд SQLite в Combobox try{ String qry = "Select name from sqlite_master where type = 'table' ;"; PreparedStatement pst = c.prepareStatement(qry); ResultSet rs = pst.executeQuery(); while (rs.next()){ dcb.addElement(rs.getString("name")) ; } jComboBox1.setModel(dcb); } catch(Exception e){ System.out.println(e); } // Выбор элемента из Combobox jComboBox1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ie) { String sa = (String)jComboBox1.getSelectedItem(); //Запись в jList try{ String qry = "Select * from '"+sa+"' ;"; PreparedStatement pst = c.prepareStatement(qry); ResultSet rs = pst.executeQuery(); while(rs.next()){ dlm.addElement(rs.getString("word")); } jList1.setModel(dlm); pst.close(); rs.close(); }catch(Exception e){ System.out.println(e); } }); }