Here you go :
String [] string = {"city","town","country","province"};
java.util.List<String> list = new ArrayList<String>(Arrays.asList(string));
Object[] arrayObject= list.toArray();
String [] data = Arrays.copyOf(arrayObject, arrayObject.length,String[].class); // java 1.6+
JComboBox<String> combo = new JComboBox<>( data);
Actually you can do :
String [] string = {"city","town","country","province"};
java.util.List<String> list = new ArrayList<String>(Arrays.asList(string));
JComboBox< java.util.List<String>> combo = new JComboBox<>( );
combo.addItem(list);
but , for every single elemen of JComboxBox
will hold all elements of list in a row.
*To prevent ambiguity between java.util.List
& java.awt.List
, we should declare them clearly.
Here the complete demo :
import java.awt.*;
import javax.swing.*;
import java.util.*;
public class ComboBoxDemo extends JFrame {
public ComboBoxDemo() {
super("JComboBox Demo");
String [] string = {"city","town","country","province"};
java.util.List<String> list = new ArrayList<String>(Arrays.asList(string));
Object[] arrayObject= list.toArray();
String [] data = Arrays.copyOf(arrayObject, arrayObject.length,String[].class); // java 1.6+
JComboBox<String> combo = new JComboBox<>( data);
setLayout(new FlowLayout(FlowLayout.CENTER));
add(combo, BorderLayout.CENTER);
}
public static void main(String[] args) {
ComboBoxDemo g = new ComboBoxDemo();
g.setVisible(true);
g.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
g.setBounds(100, 100, 300, 300);
}
}

And the result of
JComboBox< java.util.List<String>> combo = new JComboBox<>( );
combo.addItem(list);
declaration :
