Good day. Tell me, please, how to change the JList list depending on the JComboBox? I need to write a simple dictionary where a list of words in one language is given via JList, and you can choose a language through JComboBox and depending on which language you choose, you need to change this list to the selected one.
Approximate view:

FormClass.java
import java.awt.BorderLayout; import java.awt.GridLayout; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.Scanner; import java.util.Vector; import javax.swing.*; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; public class FormClass extends JFrame { JTextField text; JButton button; JList list; JComboBox combo; JPanel panel; String[] eng, rus, temp; String line; int tempIndex, choice; public FormClass() throws FileNotFoundException{ setLayout(new BorderLayout()); panel = new JPanel(); panel.setLayout(new GridLayout(1, 2)); text = new JTextField(); button = new JButton("Search"); File file = new File("input.txt"); Scanner sc = new Scanner(file); temp = new String[(int) file.length()]; while(sc.hasNextLine()){ line = sc.nextLine(); temp = line.split("="); } rus = new String[temp.length]; eng = new String[temp.length]; for(int i = 0; i < temp.length; i++){ if(i % 2 != 0){ rus[i] = temp[i]; }else{ eng[i] = temp[i]; } } list = new JList(eng); list.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { // TODO Auto-generated method stub tempIndex = list.getSelectedIndex(); text.setText(rus[tempIndex + 1]); } }); combo = new JComboBox(); combo.addItem("Eng"); combo.addItem("Rus"); combo.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { // TODO Auto-generated method stub } }); panel.add(text); panel.add(button); add(panel, BorderLayout.NORTH); add(list, BorderLayout.CENTER); add(combo, BorderLayout.SOUTH); } } MainClass.java
import java.io.FileNotFoundException; import javax.swing.WindowConstants; public class MainClass { public static void main(String[] args) throws FileNotFoundException { // TODO Auto-generated method stub FormClass form = new FormClass(); form.setSize(300, 300); form.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); form.setVisible(true); } }