Ignoring JList selections (read: wanting to ignore them)

Hi all,

I'm continuing my voyage into the wonderful world of Swing and have yet again stumbled on something that is probably very trivial (at least if you know the answer :-)).

the problem situation is the following:

I display a JList with X-rows. Everytime when a user selects a row by clicking on it with the mouse it starts a background process that lasts between 0.1 and 10 seconds. What I want to happen during this time is that the user is not allowed to select any other value in the list until the process has finished.

The current problem is that if the user clicks around the list while this process is running the gui "remembers" each click and executes them after the process has finished in the selected order (kind of queues them up). This of course might be a highly desirable functionality in some cases but makes my app. go Microsoft and that doesn't look good on the UI.

I tried using to set the lists isEnabled to false while the process is executing but this doesn't solve the problem as it still seems to register every click and just waits until the list is enabled again and then executes each one of them.

Ideal outcome: When the user clicks on an item in the list the application ignores every other selection made during the execution of the process.

So maybe something similar to a modal state where you lock the app. while the process is executing.

Thanks in advance to all you good people around the world for at least reading this lengthy description (funny thing this internet, isn't it ?).

Regards,

Kalle

[1615 byte] By [kpokki] at [2007-9-27 15:02:49]
# 1

Is your background process in a different thread ?

At a guess you need to put it into a different thread, disable the

window (or just the list) while that thread executes, then re-enable it

all when the thread exits.

...of course someone else may have a much better answer !

john3136 at 2007-7-5 23:02:58 > top of Java-index,Archived Forums,Swing...
# 2
Thanks for the answer, but unfortunately that doesn't seem to stop the queueing up of actions that the user performs during this time...Maybe I just have to approach this a bit differently if this isn't the way to go.- Kalle
kpokki at 2007-7-5 23:02:58 > top of Java-index,Archived Forums,Swing...
# 3

The approach given works for me (I'm doing something similar). Make sure you disable the list, then start the thread that does your other process. Then use something like:

[code]

SwingUtilities.invokeLater(new Runnable()

{

public void run()

{

myList.setEnabled(true);

}

};

jrduncans at 2007-7-5 23:02:58 > top of Java-index,Archived Forums,Swing...