I think you will have to use one of the class's methods. You can experiment the same as I would have to experiment to find it. You will learn something by doing the experiments that will help you in...
Type: Posts; User: Norm
I think you will have to use one of the class's methods. You can experiment the same as I would have to experiment to find it. You will learn something by doing the experiments that will help you in...
Do you have the API doc? Read it looking for any methods that will do what you want. Try all that look useful with lots of different combinations of arguments and see if any of them do what you want.
I'd use one of the JComboBox methods.
Have you tried any of the JComboBox class's methods to change what is shown?
Can you show an example by making a list and adding comments to describe the problem:
first item << can see this one
second item
third item
What happens when you execute the insertItemAt("",0) method?
Where is the empty String added?
When you wanted to insert the empty String into the list.
Please make a small, simple program that compiles, executes and shows the problem.
What variable has the null value?
What is the purpose of that code? It is useless for testing.
The message seems unrelated to anything that the user has selected.
For testing the program must compile and execute. The code you posted will not compile.
The purpose of the test program is to find a way to detect if the user has made a selection in the...
Do you have any listeners for the JComboBox? When are they called?
Is there a listener for when a user selects an item?
If that listener is not called, does that mean that the user has not...
Determine if THE USER has selected anything by using a listener that sets a flag if the user has selected anything.
When the button is pressed, test if the flag is set. If the flag is not set, the...
I thought your problem was detecting when nothing had been selected in the JComboBox before the button was pressed.
Write test code that prints out the values returned by the JComboBox methods to see what they are.
Try using one/some of the JComboBox methods to set a condition that could be tested for.
Have a...
What do the methods of the JComboBox return when nothing has been selected?
Can your code remember if a selection has been made or not?
Can the program know if an item was selected? Suppose it could determine that?
If you know that, can you decide what the program should do when the user press the button?
Is this what is...
Please explain the problem with using the methods of the JComboBox class to determine what the user has done or not done.
You can add a listener to the JComboBox class that will be called when the user selects an item.
It also has methods about what has been selected.
Read the API doc for the methods.
Can you explain what variables have what values that you could test for the "condition"?
Like x > 10 or String not equal to "ASD"