when i used the method setSelectedItem(null) it brings me null when i want to get the value from the jcomboBox no matter if pressed something else... this is my code:
import javax.swing.JComboBox;
import javax.swing.JFrame;
public class ddd extends JFrame{
final static String[] arr= {"A","B"};
public ddd()
{
super("exp");
setSize(300,200);
JComboBox<String> cb=new JComboBox<String>(arr);
add(cb);
cb.setSelectedItem(null);
String s=(String)cb.getSelectedItem();
System.out.println(s);
setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
new ddd();
}
}