1

I dont know why my combo box freezes after choosing a date.

This is the code for the combobox:

String[] name_bike= {"S","x","x"};
JComboBox comboBox = new JComboBox(name_bike);

comboBox.setBackground(UIManager.getColor("TextField.selectionBackground"));
comboBox.setSelectedIndex(1);
comboBox.setBounds(132, 199, 148, 30);
panel.add(comboBox);

This is for my database:

SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd");
String addDate=dateFormat.format(dateChooser.getDate());
ps.setString(3, addDate);

ps.setString(4,(String) comboBox.getSelectedItem());
ps.executeUpdate();
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Luffy123
  • 47
  • 6
  • As far as I know, there is no "datechooser" in _Swing_. At least, not one that comes with the JDK. Is it third party? And I don't understand how the `combobox` in the first code snippet you posted is related to the `PreparedStatement` in the second code snippet. Can you explain how they are related? – Abra Jun 12 '19 at 10:18
  • datechooser is a variable for JDateChooser . In order to get the selected item from combobox . – Luffy123 Jun 12 '19 at 11:25
  • I found a few `JDateChooser` components on the Internet. I'm sorry but my crystal ball is being repaired right now so you need to help me a bit more. Forgive my ignorance, but can you tell me where your `JDateChooser` component comes from? Is it [this one](http://jdatechooser.sourceforge.net/) ? Or maybe [this one](http://plugins.netbeans.org/plugin/658/jdatechooser-1-2) ? – Abra Jun 12 '19 at 18:44
  • Its from jCalendar jar. – Luffy123 Jun 13 '19 at 03:36
  • Do you mean this [JCalendar](https://toedter.com/jcalendar/)? – Abra Jun 13 '19 at 04:35
  • yes its the one – Luffy123 Jun 13 '19 at 06:56
  • I copied the image of `JDateChooser` component from the _JCalendar_ website and [uploaded it](https://imgur.com/a/LZfKeob). I don't see any "combo box" in the image, so I don't understand which combo box freezes. If you post a [mcve], I can copy your code and try to reproduce your problem. Which java version are you using? – Abra Jun 13 '19 at 07:30

0 Answers0