01: package net.xoetrope.samples.ctlsamples;
02:
03: import java.awt.event.MouseEvent;
04:
05: import net.xoetrope.awt.XHotspotImage;
06: import net.xoetrope.awt.XLabel;
07: import net.xoetrope.xui.XPage;
08: import net.xoetrope.xui.XResourceManager;
09:
10: public class Hotspots extends XPage {
11: XHotspotImage classImage;
12: XLabel lblInfo;
13:
14: public Hotspots() {
15: lblInfo = (XLabel) componentFactory.addComponent(XPage.LABEL,
16: 10, 250, 90, 60, "", "XEdit");
17: classImage = (XHotspotImage) componentFactory.addComponent(
18: XPage.HOTSPOTIMAGE, 0, 0, 345, 331,
19: "classhierarchy.gif");
20: addMouseHandler(classImage, "handleHotspotsClicks");
21: setupHotspots();
22: }
23:
24: public void setupHotspots() {
25: try {
26: classImage.read(XResourceManager.getBufferedReader(
27: "classhotspots.xml", null));
28: } catch (Exception ex) {
29: ex.printStackTrace();
30: }
31: }
32:
33: public void handleHotspotsClicks() {
34: if (wasMouseClicked()) {
35: MouseEvent evt = (MouseEvent) getCurrentEvent();
36: int clicked = classImage.checkHotspot(evt.getPoint());
37: String spotName = classImage.getName(clicked);
38: lblInfo.setText(spotName + " was clicked");
39: }
40: }
41: }
|