ASE Home Page Products Download Purchase Support About ASE
ChartDirector General
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Use MouseClick in JavaFrames
Posted by satay on Jul-01-2013 11:49
How to Use MouseClick in JavaFrames

How to put chart in JFrame and Handle mouse Click opeartions??

Give Sample Progarmme Plz........

  Re: Use MouseClick in JavaFrames
Posted by Peter Kwan on Jul-02-2013 01:08
Hi satay,

If you are referring to clicking the "hot spots" on the chart (eg. the bars in a bar chart, the slices in a pie chart, etc), you may add a HotSpotListener. In the original "ChartDirectorDemo" sample code, almost all charts are clickable using this method.

In brief, the code is like:

//handle hot spot mouse events
viewer.addHotSpotListener(new HotSpotAdapter() {
   public void hotSpotClicked(HotSpotEvent e) {
      System.out.println("Data Value = " + e.get("value"));
   }});

You may optionally use ChartViewer.setHotSpotCursor to provide mouse cursor feedback when the mouse is over a hot spot. For example, if you want the mouse cursor to change to a hand shape, the code is like:

viewer.setHotSpotCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

Hope this can help.

Regards
Peter Kwan