Creating a Fixed Watch

A normal watch describes the content of a variable, and a fixed watch describes the object that is currently assigned to the variable. You can create a fixed watch from a normal watch that has been assigned to a variable.

For example, consider the following code:

java.awt.Dimension dim=new java.awt.Dimension(10,20);
java.awt.Dimension newDim=dim;
dim=new java.awt.Dimension(20,30);
newDim.height=15

With the debugger stopped on the second line, you can create a normal watch on the variable dim. If you create a fixed watch on the variable dim, the watch describes the object that is currently assigned to the variable, which is java.awt.Dimension(10,20)). If you press F8 to step over the code three times, the value of the normal watch becomes java.awt.Dimension(20,30). (This change occurred on the third line of source code.) The value of the fixed watch is java.awt.Dimension(15,20). The fixed watch was created on the object with a height of 10, but the fourth line changed the height of this object to 15.

To set a fixed watch:

  1. In the Watches tab of the Debugger window, select the watch.
  2. Right-click and choose Create Fixed Watch.

    A new node appears in the Watches tab and shows the current value of the watch variable or expression.

Tip You can also create a fixed watch on a variable in the Variables tab. Select the variable, right-click, and choose Create Fixed Watch.
See also
Watching the Value of a Variable or Expression
Deleting a Watch Variable or Expression

Legal Notices