The goal for the lab is to better understand buttons, panels, and good coding techniques. We will add two more command buttons in the Conversation system so that the user may have more control. And we'll get those buttons out of the grid so the system looks good again. Note that part of looking good includes being able to see everything, which may mean shrinking your picture size a bit. Generally speaking it's a good idea to keep the pictures all the same height and let the width vary a bit. We'll be inspecting the results at the end of the lab.

  1. Same partners, switch roles.

  2. Add command buttons to start and stop the talking. The rulers should not start talking until the Start Button is pressed. As with the report button added last time, these new buttons will be huge as they're entered into the grid with the rulers.

  3. To get the buttons out of the grid, we need two new panels inside Conversation, a buttonPanel and a rulerPanel. The idea is that the buttons will go into the buttonPanel and the Rulers will go into the rulerPanel.

    • These new panels as usual will need to be declared, initialized and added to the Conversation panel.

    • You should declare the panels at the top with all the other variables, but do the initializing in two new methods, initButtonPanel() and initRulerPanel().

  4. Move the initialization of the buttons to the new initButtonPanel()  method. Change the add statements so that the buttons are added to the buttonPanel. {Currently they are in the Conversation panel.} buttonPanel.add(....

  5. Similarly, move the ruler initializations to the new initRulerPanel().

    • The rulerPanel should have a grid layout. So, instead of setLayout(new GridLayout(3,2)), you'll have rulerPanel.setLayout(new GridLayout(3,2)).

    • Move creating the Rulers and adding them to the graphics system to the initRulerPanel() method. Keep the existing createRulers and addRulers methods but call them from initRulerPanel().

    • In the addRulers method: change add(rulerList[i]) to rulerPanel.add(rulerList[i]).

  6. At this point the buttons should be at the top (or perhaps to the left) and the rulers should be laid out in a grid underneath the buttons. If you've got that reversed, look at the order in which you're initializing things.

  7. The conversation panel itself used to have a grid layout. Make it a box layout instead to ensure that the buttons always end up above the grid. See information on BoxLayouts in the Lab 14 notes on Blackboard.

  8. Given all the layouts we have in place the system should adjust to the size of the individual Ruler panels. This means we shouldn't have to set the size in Conversation any more. You can remove the line of code that does that, if you haven't already. Now, experiment with (remove, change) the line of code in Ruler that sets the ruler's size.

  9. Email your Conversation.java file and the screenshot of your graphics frame. Email 2 images: one before any buttons are pressed and one after Report and StartTalking are pressed.

  10. Show your running code. If you don't finish in lab, then email all code, pictures, and 2 screenshots of your graphics frame. Blackboard is optional.

  11. Be sure your partner has all code and all pictures.