plot.add(contents);
plot.setPreferredSize(new Dimension(150, 100));
contentPane.setBackground(Color.darkGray);
XYLocationDisplay locationDisplay = new XYLocationDisplay();
// This is a hack to set the preferred height to the normal height so the component doesn't collapse to height 0 when the text is empty.
// Note that mimimumSize does not work for some reason.
locationDisplay.setText("Ag");
Dimension size = locationDisplay.getPreferredSize();
size.width = 100;
locationDisplay.setText("");
locationDisplay.setPreferredSize(size);
// End hack
locationDisplay.setForeground(Color.white);
locationDisplay.setFont(new Font("Arial", 0, 12));
locationDisplay.setFormat(new MessageFormat("<html><b>X:</b> {0} <b>Y:</b> {1}</html>"));
locationDisplay.attach(plot);
plot.add(locationDisplay);
SlopeLine slopeLine = new SlopeLine();
slopeLine.setForeground(Color.white);
slopeLine.attach(plot);