Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to queue up a bunch of user driven java swing events
    primarykey
    data
    text
    <p>I have a bunch of checkboxes and radio buttons that allow a user to filter out items in a <code>JTable</code>.Each of the events need to be threaded to avoid the GUI freezing up. </p> <p>What I would like to do is queue up the events and act on them in the order they were received.</p> <p>Currently I have the following design but I think there must be a better way. Basically, I have for each potential queued method, an integer that maps to it. That integer value is added to a list in each <code>actionPerformed</code> method execution of integers that are looped through and translated to function calls. </p> <p>I was possibly thinking about using a EventQueue to call run on it. What is the best pattern or technique for this type of functionality?</p> <pre><code>Vector&lt;Integer&gt; taskQueue; /** * Adds tasks to a queue things are completed in the order they were added. This allows for * threading and concurrency issues.One task is done at a time. * @param */ private void doTasks() { if(!queueIsRunning) { doTasks = new Thread(){ public void run() { queueIsRunning = true; while(!taskQueue.isEmpty()) { intVal = taskQueue.get(0); taskQueue.remove(0); switch(intVal) { case DOM_HIGHLIGH_TASK: System.out.println("starting dom highlight"); highlightDom(); break; case FLASH_HIGHLIGH_TASK: System.out.println("starting flash highlight"); higlightFlash(); break; case SQL_HIGHLIGH_TASK: System.out.println("starting sql highlight"); highlightSQL(); break; case INFO_HIGHLIGH_TASK: System.out.println("starting infoleak highlight"); highlightInfoLeak(); break; case HTMLCOM_HIGHLIGH_TASK: System.out.println("starting htmlcomm highlight"); highlightHtmlComments(); break; case SORT_EXTENSIONS: sortExtensions(); } } queueIsRunning = false; } }; doTasks.start(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload