Even I was confused why this problem occurred to me. I mean, I have another JComboBox cell editor used in another JTable and there was no problem with the selection highlight when I pressed either the up or down arrow key to navigate through the items.

i double checked line by line and compared my two classes to ensure that there is nothing different with the two of them. And still, the selection highlight problem persisted.

Luckily, there is a property that you can set to a JComboBox cell editor to highlight the selected item when you use the up and down arrow keys.

If you encounter this problem, avoid debugging your code and use this property right away. It took me some time to find out the solution but the fix is pretty quick.

If you want to have your ListView widget for viewing purposes only, chances are you may want to remove those annoying default highlight orange color when you click on any rows, plus the black background color that engulfs the whole ListView.

You need to do two things. Add these two attributes in your ListView object and you are good to go.

There is a 3rd attribute that you may want to use when you select the ListView and scroll it down, you will notice there is an orange line at the top. If you want to remove that, then add this attribute:

The image in this post shows how the highlight matching code works with a JTextPane. But actually, the code uses a JTextComponent so either a JEditorPane, JTextArea or JTextPane will work with this code.

Type in the word that you want to find, then press the FIND button and it will highlight all words matching it. The highlight matching is case insensitive so if you want to make it case-sensitive, just remove the part of the code where toLowerCase() is called.

To use the class, just do it like this:

And here is the source code for the WordEditorSearch class.

Related Posts Plugin for WordPress, Blogger...