•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 423,612 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,133 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 353 | Replies: 1
![]() |
•
•
Join Date: Mar 2007
Posts: 15
Reputation:
Rep Power: 2
Solved Threads: 0
I have a ComboBox defined as follows:
private String[] months = {"Month", "01", "02", "03", "04", "05", "06", "07", "08",
"09", "10", "11", "12"};
private JComboBox jComboBoxMonth = null;
and down further I have:
jComboBoxMonth = new JComboBox(months);
Now i am trying to do run an if statement which checks to see if the word "Month" is what is appearing in the ComboBox. So down further I have:
if (jComboBoxMonth.equals("Month") {
and my code is here.
Is the above test in the if statement being carried out, as i suspect that it isn't.
Anyone any ideas.
Thanks
Paidi
private String[] months = {"Month", "01", "02", "03", "04", "05", "06", "07", "08",
"09", "10", "11", "12"};
private JComboBox jComboBoxMonth = null;
and down further I have:
jComboBoxMonth = new JComboBox(months);
Now i am trying to do run an if statement which checks to see if the word "Month" is what is appearing in the ComboBox. So down further I have:
if (jComboBoxMonth.equals("Month") {
and my code is here.
Is the above test in the if statement being carried out, as i suspect that it isn't.
Anyone any ideas.
Thanks
Paidi
•
•
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,434
Reputation:
Rep Power: 11
Solved Threads: 295
No, you have to first call currently selected item
and then you can compare it as you did it
String selectedOption = (String) jComboBoxMonth.getSelectedItem()and then you can compare it as you did it
if (selectedOption.equals("Month") Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Java Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Display Value in JcomboBox (Java)
- JComboBox -- Item is not in the list???????? (Java)
- Advanced : Reading Memory and Comparing (C)
- SAS help: comparing individual observations (Computer Science and Software Design)
- Comparing Images For Similarity (Java)
- Array or String Comparing Assignment (C++)
- Essay help:comparing two professions, Software Enginering and ? (Computer Science and Software Design)
Other Threads in the Java Forum
- Previous Thread: secret mission
- Next Thread: Date Validation



Linear Mode