labs / tiddlers / content / labs / lab03 / _Labs_03_The Product Viewer
@Mark George Mark George on 20 Jul 2021 2 KB WIP lab 3

We need a dialog that allows a user to view the products that have been entered into the system. Take a quick look at the mock-up of this dialog in the product specification document (section so that you know what you are aiming for.

  1. Add a new issue to GitBucket. We are about to start work on the dialog that allows the user to view the products, so name/describe the issue appropriately.

  2. Create a new JDialog in the gui package named ProductViewer.

  3. Add a Scroll Pane from the Swing Containers palette to the form. It should take up most of the form leaving a little bit at the top for the search and filter components, and a little bit of room at the bottom for then buttons. You can resize this later once you have added the other components.

  4. Add a List (JList) component to the scroll pane. A JList component is able to display a collection of objects and allow the user to select one. It is similar to a combobox but is expanded by default whereas a user needs to click the drop-down button to expand a combobox.

  5. Add a button for closing the dialog and set the variable name and text of the button to appropriate values. Make sure it is attached to one of the dialog's bottom snap boundaries.

  6. Resize the scroll pane so it snaps to the top of the button. This will make the scroll pane and list resize vertically when the form is resized. You should make sure that the scroll pane will also resize horizontally.

  7. Add a button click handler to the close button that closes the form by calling dispose().

  8. Now you can add a button handler to the <

    > button in the MainMenu frame that will display the ProductViewer dialog.

  9. Test your modification to the main menu by running the application.

  10. Now is a good time to commit. We haven't finished with this class, so don't close the issue just yet. This is the last time that we will tell you to commit. From now on you should use your own judgement on when to commit and create issues. Remember to reference the associated issue --- if you are doing things correctly then pretty much every commit should reference a corresponding issue.

    Try to get into the habit of using the issues list on GitBucket as your to-do list for the project.