FHTW Berlin

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


Exercise 4: Getting into the SWING of things

Now we will start working through some of the great Java tutorials that MageLang Institute created for Sun.

The lesson for this week is Swing 1, sometimes also called JFC (Java Foundation Classes) and can be found at

http://developer.java.sun.com/developer/onlineTraining/GUI/Swing1/index.html

  1. Read through the portions on JPanel, JIcon and JButton. Can you put an Icon on a Button? There are now three exercises, called "Magercises". Do the first three exercises.
    1. The first exercise will help you find the Swing classes. If you can find them on the machine, you will be rewarded by seeing the SwingSet Demo program. Take a few minutes to play with the demo and see what kinds of things you can program using Swing. Many of the components have dynamic behavior, so click on everything you see to see what it can do. If you go through all the components you wil be able to answer the following questions: When was MICROGRAPHIA printed? What are the names of the three bouncing babies? Whose favorite number is 13?
    2. Create your first JFC application, and make a button with an icon on top. You can use the bee and dog .gifs that are offered in the course, or use any other .gif you happen to have lying around and that you have the rights for.
  2. Now we get into AbstractButton and JCheckBox. Copy the JCheckBox code and adapt it make a selection of at least 4 check boxes. For example, you might want to have people choose their favorite food from among pizza, hamburgers, hot dogs and Eisbein mit Sauerkraut. Now read about RadioButtons and describe in your report the difference between CheckBoxes and RadioButtons.
  3. JScrollPane will now help us make some cute pictures. Start off with the tiger example that is given in the tutorial. If you are bored, pick some image off the Internet using the URL class and display the Image you created on the Icon. You will need to find some "glue" to make an Icon out of an Image. Look around!
  4. Now do the Pizza exercise (Magercise 4)!
  5. Read through the Text examples and then try the Magercise 5. Isn't it fun playing with borders!

 

 


 

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)