The lab goal is to work with events, timers, listeners and buttons. To do this, we will slow the conversation down so we can see it all and use buttons to control when the rulers report.

  1. New partners, see Announcements.

  2. In the previous version only the last conversation snippet for each Ruler shows up. We need a timer to slow down the conversation so we can see the whole thing, not just the last bit!

  3. In preparation for this, remove the for loop from converse() . Keep the body of the loop, but the idea is that it only runs once instead of repeating. If you run the system now, just one person will talk and they'll only say one thing.

  4. Based on the discussion in class, insert the appropriate import statement in your code and declare a Timer variable named conversationTimer.

  5. Initialize that variable. You'll then need to add a ConversationTimerListener class to Conversation. Here's the boiler plate for doing that:

    private class ConversationTimerListener implements ActionListener
    	// Has one ruler say hello when timer expires
    {
    	public void actionPerformed(ActionEvent evt) //ActionListener leaves this blank. We must fill
    		//it in with what we want to do when the timer goes off.
    	{
    		converse();
    	}
    }
    		
  6. In the Conversation() constructor remove the call to converse() and replace it with a line that starts the timer.

  7. Compile and run. Hmmm... They never seem to stop talking, and reporting is broken.... We'll take better control of starting and stopping the conversation next time. Let's work on reporting now.

  8. Add a "Report" button as discussed in class. The rulers should not Report until the user presses this button. Note that since we are adding this button to the Conversation panel which is laid out in a grid the button will show up as part of the grid. We'll fix this next time.

  9. As always, we need an appropriate comment on each routine and on each control structure within the routines. Make sure you're using good names for all your variables and remove any variables that aren't being used.

  10. Send Conversation and Ruler to your partner and to me.

  11. If you want to get a jump on next time, add "Stop Talking" and "Start Talking" buttons as well. Note that these will really just start and stop the timer.