Java - jList: Custom ListSelectionListener question (SSCCE Included)?

If you are trying to set the color of a row that has been selected, then that code should be done in the renderer. In general whenever you play with colors in a renderer you need the check: if (! isSelected) // do you custom rendering This way the row will still show the default highlighting as you select different rows And of course a SSCCE should still be posted because we have no idea what your custom Action is attempting to do and therefore can't make any real suggestions Edited: It doesn't do anything because all your code is doing is creating the Action. If you want to invoke the Action then the code should be something like: new Actions().

CreateTestAction(). ActionPerformed(null) In reality there is no need to create an actual Action, you just need to invoke some method directly that does what you want. The reason you create an Action would be if you wanted to add the Actdion to a JButton or JMenuItem so the user could click on the component to invoke the Action.

If you are trying to set the color of a row that has been selected, then that code should be done in the renderer. In general whenever you play with colors in a renderer you need the check: if (! isSelected) // do you custom rendering This way the row will still show the default highlighting as you select different rows. And of course a SSCCE should still be posted because we have no idea what your custom Action is attempting to do and therefore can't make any real suggestions.

Edited: It doesn't do anything because all your code is doing is creating the Action. If you want to invoke the Action then the code should be something like: new Actions(). CreateTestAction().

ActionPerformed(null); In reality there is no need to create an actual Action, you just need to invoke some method directly that does what you want. The reason you create an Action would be if you wanted to add the Actdion to a JButton or JMenuItem so the user could click on the component to invoke the Action.

Ok ok, first of all the action is supposed to do something totally irrelevant to the jList. It's supposed to give a yFiles EdgeRealiser a color. The thing is you won't be able to compile and run a SSCCE if you don't have yFiles and I do believe it will not really help.

Question is, is there any good reason why this action as it is implemented there, is not working? – devilwontcry Jun 24 '10 at 14:21 If you add a System.out. Println to the method and you see the display then the code WILL be exeucted.

Its just a matter of if you implemented the code correctly. You haven't posted the implementation of the Action so we can't tell if it should work or not. You haven't posted the code where you add the listener to the component, so again we don't know if you are doing that correctly.As I told you in your last posting we don't have time to play 20 questions guessing what you might have forgotten to code.

– camickr Jun 24 '10 at 14:40 As I answered above, I have made all the necessary "s. Out" tests and the Listener is responding. I cannot post a SSCCE here because my program needs a package yFiles that is not free, so most of the people here won't be able to compile still but I will edit my post and add some more snippets like the action and the jList initialization.

– devilwontcry Jun 24 '10 at 14:44 You still don't understand the concept of a SSCCE. I don't care about your yFiles class. The idea is to create a short, simple program that demonstrates the problem you are having.

Therefore all you need to do is create a simple Action that displays some text and you will prove that you implemented the method properly and added all the listeners properly. Then its up to you to figure out why your real Action doesn't work. Based on the updated code you posted its possible you have the variable "jList" defined twice, once as a class variable and once as a local variable.

– camickr Jun 24 '10 at 14:54 I have added a SSCCE. (Still trying to figure out what another person would need in order to help me with my solution. I am not slacking or anything camickr) – devilwontcry Jun 24 '10 at 16:05.

And of course a SSCCE should still be posted because we have no idea what your custom Action is attempting to do and therefore can't make any real suggestions. It doesn't do anything because all your code is doing is creating the Action. In reality there is no need to create an actual Action, you just need to invoke some method directly that does what you want.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions