FHTW Berlin

FB 4
Internationale Media and Computing
MeSoII: Media Software II
Sommersemester 2002


Exercise 5: Deep SWINGing

This exercise will be done by the Tuesday group on May 7 and the Thursday group on May 16. Have a safe holiday! If you must drink, don't drive! Remember that Friday is a holiday at the FHTW.

  1. First we will finish the Swing exercises from last week.
    Do Magercise 6 on Menus, Toolbars and Tooltips and 7 on Using BoxLayout
  2. The second Swing tutorial is to be found at http://developer.java.sun.com/developer/onlineTraining/GUI/Swing2/index.html.
    It can be downloaded as .pdf or read on-line. Just glance over the overview. This just lists the Listener interfaces available. The main thing is to understand the MVC architecture. MVC is a design pattern (Model-View-Controller) that separates the interface of an application from the intelligence behind the screen. This intelligence is also split into a model of what is going on and a controller that understands how the application is to behave. There can be different views that latch on to the same models and controllers. What this means, is that you can switch out the entire GUI ("Look and feel") without disturbing the logic of the system. We saw an example of this last week.
    Pages 15 and 16 have a simple Swing GUI example (SimpleEvents). Copy the code, compile and run it. Pushing the button *changes* the contents of the window. Try and add another button that sets the contents of the window to a default value such as "I feel great!!".
  3. Page 17-20 have an example that uses a simple, AWT style of making a UI. Every time you enter something in the TextField it will be added to the TextArea. Copy this, compile it and run it. Read through the problems discussed after the example. Do you understand this? Summarize in your own words in your report. A central problem is that you have no guarantee that actions will be performed in any order. If you really want to understand the problem, try and implement a window that has one TextField that takes numbers, adds them to a List in a TextArea, and at the same time calculates the current average of the numbers.
  4. Read on and then meditate on the structure on page 22.You need a ListView in order to have this work. You need the three classes ListView, IntVectorModel, and FirstMVC in order to make it work. This means, of course, that you will need to put each of these classes in their own file!! Copy the code, compile it, and see that it works! Now add a field that displays the current maximum and current minimum value of the sequence of numbers!

 


 

The URL to your report, which will describe what you did during the exercise and include links to your code, is due in my email box by the start of exercise 4. This means Tuesday at 8.00 for Group 1 and Thursday at 12.00 for Group 2. Do not forget to put your names on the report! When you send the URL to me, include your partner in the CC. That way I don't get either 2 emails or none, while each thought the other was doing it. And when I answer you, I can immediately answer both of you without having to look up your preferred email account.

 


Debora Weber-Wulff (weberwu@fhtw-berlin.de)