Help! I am using jdk 1.6, but Intellij6 disagrees with 1.6 syntax.

I set Intellij6 to use jdk 1.6, but it does not seem to be using the SUN jdk. The SUN jdk documentation states that List.setSelectedIndex does not exist for java.awt.List, but Intellij6 thinks it does. The SUN jdk states the correct method is List.select, but Intellij6 thinks that method doesn't exist.

What can the problem be?

4 comments
Comment actions Permalink

Ok. I was wrong. I am dealing with a JList so IntelliJ is probably correct.

But I still have a problem. The following code yields index11test = "-1". But it's set to 1 in the previous step. How is this possible?

list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.addListSelectionListener(this);
list.setSelectedIndex(1);
int index11test = list.getSelectedIndex();
System.out.print(index11test);

0
Comment actions Permalink

Most probably your list is empty. You can't set the selected index to 1
if there are less than 2 elements in the list.

Gliphi wrote:

Ok. I was wrong. I am dealing with a JList so IntelliJ is probably correct.

But I still have a problem. The following code yields index11test = "-1". But it's set to 1 in the previous step. How is this possible?

list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.addListSelectionListener(this);
list.setSelectedIndex(1);
int index11test = list.getSelectedIndex();
System.out.print(index11test);

0
Comment actions Permalink

I think the problem is something else. The selected index comes out -1 no matter what size the model is (I tried 1,2,3,4 entries in the list with the same result).

0
Comment actions Permalink

The problem isn't inside the few lines you posted before, as they work
exactly as expected. So you should post your complete example in order
to get real help.

Gliphi wrote:

I think the problem is something else. The selected index comes out -1 no matter what size the model is (I tried 1,2,3,4 entries in the list with the same result).

0

Please sign in to leave a comment.