Suggested Projects


Skill-Building Exercises

  1. Skill with Coordinates:   Write a “joke” application that displays a JFrame containing a “Quit Application” button whose ActionListener quits the application. Unfortunately for the unsuspecting user, this button always moves away from the cursor just far enough to elude a mouseclick. No matter where the button moves, it must not move outside the bounds of the window. To be nice, make sure that pressing the “Enter” key will trigger the button’s actionPerformed() handler.

  2. Handling Images:   Extend JPanel to create a BackgroundPanel class. This class should allow an image to be used as the panel’s background. The panel should resize or tile its image (depending on the mode) as necessary to always completely fill its bounds. The image’s colors should be muted by a configurable amount through the use of transparency.

  3. Handling Images (Trickier):   Extend JList to create a BackgroundList class. This class should allow an image to be used as the JList’s background. The JList should resize or tile its image (depending on the mode) as necessary to always completely fill its bounds. The image colors should be muted by a configurable amount through the use of transparency. Whatever component serves as the ListCellRenderer component should have a transparent background so that the list’s own background shows through.

  4. Fine-Tuning the API:   The editor for the JTree in DemoFrame leaves something to be desired. To view the problem, run the DemoFrame application, edit a node in the tree by deleting all its text and press the “Enter” key to stop editing. Now try to edit it again by typing text back into it. Figure out what’s happening and implement a solution for it.

  5. Assimilating your Knowledge:   Modify the DemoTreeAndTable class to display a pop-up menu that appears when the user right-clicks a table row. This menu should provide a “Delete Row” menu item that deletes the clicked row, an “Insert Row Before” menu item that inserts a row before the clicked row and an “Insert Row After” menu item that inserts a row after the clicked row.

  6. Writing a DragTable:   Following the pattern set by DragList as much as possible, write a DragTable class that extends JTable and allows reordering of rows.




Java For Artists(c) The Art, Philosophy, and Science of Object-Oriented Programming
Java For Artists: The Art, Philosophy, And Science Of Object-Oriented Programming
ISBN: 1932504052
EAN: 2147483647
Year: 2007
Pages: 452

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net