Tool Tips
Swing supports tool tips, small help boxes that pop up when the mouse hovers over some element. The
ToolTip node allows tool tips to be associated with chart elements. The text displayed in the tool tip is the
Title attribute of the
ToolTip’s parent node.
Example
In this example two
Data nodes are created. Each
Data node has a
Title defined and a
ToolTip node added as a child. Note that the
ToolTip node just has to be created, no methods using it are normally required.
import com.imsl.chart.*;
import java.awt.Color;
public class SampleToolTip extends JFrameChart {
public SampleToolTip() {
Chart chart = getChart();
AxisXY axis = new AxisXY(chart);
double y1[] = {4, 6, 2, 1, 8};
Data data1 = new Data(axis, y1);
data1.setDataType(Data.DATA_TYPE_MARKER);
data1.setMarkerColor(Color.red);
data1.setMarkerType(Data.MARKER_TYPE_FILLED_CIRCLE);
data1.setTitle("Set A");
new ToolTip(data1);
double y2[] = {7, 3, 4, 5, 2};
Data data2 = new Data(axis, y2);
data2.setDataType(Data.DATA_TYPE_MARKER);
data2.setMarkerColor(Color.blue);
data2.setMarkerType(Data.MARKER_TYPE_FILLED_SQUARE);
data2.setTitle("Set B");
new ToolTip(data2);
}
public static void main(String argv[]) {
new SampleToolTip().setVisible(true);
}
}