Exercises

Bruce Eckel's Thinking in Java Contents | Prev | Next

  1. Create an applet with a text field and three buttons. When you press each button, make some different text appear in the text field.
  2. Add a check box to the applet created in Exercise 1, capture the event, and insert different text into the text field.
  3. Create an applet and add all the components that cause action( ) to be called, then capture their events and display an appropriate message for each inside a text field.
  4. Add to Exercise 3 the components that can be used only with events detected by handleEvent( ). Override handleEvent( ) and display appropriate messages for each inside a text field.
  5. Create an applet with a Button and a TextField. Write a handleEvent( ) so that if the button has the focus, characters typed into it will appear in the TextField.
  6. Create an application and add to the main frame all the components described in this chapter, including menus and a dialog box.
  7. Modify TextNew.java so that the characters in t2 retain the original case that they were typed in, instead of automatically being forced to upper case.
  8. Modify CardLayout1.java so that it uses the Java 1.1 event model.
  9. Add Frog.class to the manifest file shown in this chapter and run jar to create a JAR file containing both Frog and BangBean. Now either download and install the BDK from Sun or use your own Beans-enabled program builder tool and add the JAR file to your environment so you can test the two Beans.
  10. Create your own Java Bean called Valve that contains two properties: a Boolean called “on” and an integer called “level.” Create a manifest file, use jar to package your Bean, then load it into the beanbox or into your own Beans-enabled program builder tool so that you can test it.
  11. (Somewhat challenging) Change Menus.java so that it handles cascading menus.
A



Comments

  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Java developers know that testing code changes can be a huge pain, and waiting for an application to redeploy after a code fix can take an eternity. Wouldn't it be great if you could see your code changes immediately, fine-tune, debug, explore and deploy code without waiting for ages? In this white paper, find out how that's possible with a Java plugin that drastically changes the way you develop, test and run Java applications. Discover the advantages of this plugin, and the changes you can expect to see …

  • Live Event Date: August 20, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT When you look at natural user interfaces as a developer, it isn't just fun and games. There are some very serious, real-world usage models of how things can help make the world a better place – things like Intel® RealSense™ technology. Check out this upcoming eSeminar and join the panel of experts, both from inside and outside of Intel, as they discuss how natural user interfaces will likely be getting adopted in a wide variety …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds