CS4470: Assignment 4

"Debugging Magic Lens'"

Due: November 17th


Purpose

The goal of this assignment is to create the class JDebugFrame, which is an alternate JFrame that includes one or more "debugging lenses" to help you see the structure of the underlying Swing widgets. The lenses will be drawn in the GlassPane of the frame's RootPane.

To see what you need to create, see the "debugging lens" example at the end of section 2 of the Subarctic Manual. The basic assignment should implement the exact same lens. The optional, extra credit part of the assignment should implement an additional lens of your design.

Task: JDebugFrame

You should design your subclass of JFrame, called JDebugFrame, so that it can be substituted in to any Swing application that uses JFrame (except those that use the glass pane for something else!). When the user presses shift-ctrl-leftbutton, the lens should appear (when it is pressed again, the lens should disappear). The lens should work with any application, not just those you build; in other words, your debug frame should not know anything about the components under it ahead of time, but should find out about them by inspecting the component hierarchy. Notice, also, that keyboard and mouse events are passed through the lens to the components below.

Basic Debugging Lens

The basic lens can be moved around inside the glass pane, and shows some attributes of the widgets in the JFrame below it, just as the SubArctic example. The lens should have the same controls in it to turn on and off the various display items. If you cannot easily create a dual-slider scroll bar for the depth and children range, you may use two separate sliders that are constrained to valid values.

Optional Lens

For extra credit, create a second lens that can be activated with shift-control-right button, that displays a completely different set of information (when it is pressed again, the lens should disappear). What the lens displays is up to you, but it should be something that is useful in debugging Swing applications. You will be graded on the usefullness of the lens and the implementation. Extra credit of up to 2 points can be earned.

Turn In

Your program should consist of a set of java files which should be commented with your name (the name you are registered under!). The java file should implement a class "A4" (so the TA can save it as "A4.java", compile it and execute it using the command "java A4".) The files should be emailed to cs4470@cc.gatech.edu.

The time the mail is received will be used to determine whether or not the program is late, so be sure to allow a couple of minutes for the mail system to transmit your file if you are working right up to the deadline.

IMPORTANT: If the TA has to edit your files you will lose points. Similarly, the TA should be able to execute the class "A4", so using any other class as your main class will result in lost points.

You must submit both the JDebugFrame class, and at least one test application that demonstrates it; the application need not be overly complex, or even be "useful" as an application. You should probably use your previous assignments as test cases, but need not submit them.

You MUST create a class called JDebugFrame that can be used with other Java applications. The TA will grade your assignment by using your class with both your Swing application, and other Swing applications of his own design.

Due date

Additional Instructions

You must pass events through the GlassPane, and through the transparent part of the debug lens. Since you will request mouse events, you need to make sure that any mouse events that are not used in your lens widgets are passed on to the underlying contentPane. Check out the SwingUtilities package for help in figuring out where to send the event (and how to convert it to the correct destination coordinates), and look at the Component object for to see how to redispatch the event.

As described above, you should use the GlassPane for the container of your debugging lens. You can use a JInternalFrame inside the GlassPane to facilitate the debugging lens: it will not look quite as "minimal" as the SubArctic example, but will have the same effect. To be able to see everything underneath the JInternalFrame, you have to turn 3 panes transparent: the JInternalFrame, LayeredPane and the ContentPane.

Here are some additional hints: