Java Reference
In-Depth Information
Figure 11-8.
Changing the resize weight
Listening for JSplitPane Property Changes
The
JSplitPane
class defines the following constants to help with listening for bound property
changes:
•
CONTINUOUS_LAYOUT_PROPERTY
•
DIVIDER_LOCATION_PROPERTY
•
DIVIDER_SIZE_PROPERTY
•
LAST_DIVIDER_LOCATION_PROPERTY
•
ONE_TOUCH_EXPANDABLE_PROPERTY
•
ORIENTATION_PROPERTY
•
RESIZE_WEIGHT_PROPERTY
One way of listening for when the user moves the divider is to watch for changes to the
lastDividerLocation
property. The example in Listing 11-2 attaches a
PropertyChangeListener
to a
JSplitPane
displaying the current divider location, the current last location, and the previous
last location. The component above and below the divider is the
OvalPanel
class (discussed in