Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8593215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:56:17+00:00 2026-06-11T23:56:17+00:00

I want to set dots in my app with mouse click. I use JFreeChart

  • 0

I want to set dots in my app with mouse click. I use JFreeChart and use in ChartPanel mouse listener. This is look like this:

panel.addChartMouseListener(new ThisMouseListener());

and my mouse listener ThisMouseListener() (it is not finished):

class ThisMouseListener implements ChartMouseListener{

    @Override
    public void chartMouseClicked(ChartMouseEvent event) {
        int x = event.getTrigger().getX();
        int y = event.getTrigger().getY();

        System.out.println("X :" + x + " Y : " + y);

        ChartEntity entity = event.getEntity();
        if(entity != null && (entity instanceof XYItemEntity)){
            XYItemEntity item = (XYItemEntity)entity;
        }
        new JOptionPane().showMessageDialog(null, "Hello", "Mouse Clicked event", JOptionPane.OK_OPTION);
    }

    @Override
    public void chartMouseMoved(ChartMouseEvent arg0) {
        // TODO Auto-generated method stub

    }

} 

but this mouse listener returns me my panel coordinates and I want to get coordinates from my chart. May be I must use listener with other object? or I can transform coordinates with some method?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T23:56:18+00:00Added an answer on June 11, 2026 at 11:56 pm

    You added the listener to the panel. Therefore when you click the mouse you receive coordinates relative to the panel – which is the source of the event. You need to add this listener to the chart instead.

    Other possibility is to get coordinates of the chart in respect to panel and subtract them from x and y.

    Point p = chart.getLocation();     
    int px = p.getX();
    int py = p.getY();
    
    x = x-px; // x from event
    y = y-py; // y from event
    // x and y are now coordinates in respect to the chart
    
    if(x<0 || y<0 || x>chart.getWidth() || y>chart.getHeight()) // the click was outside of the chart
    else // the click happened within boundaries of the chart and 
    

    If the panel is the container of the chart component your solution might look something like the above one. Note that these coordinates will be coordinates in respect to left top corner of the chart.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have file like this 1248812832.v.doc and i want to remove strings and dots
I want to set a repeating alarm monthly; but my app resets the alarm
I want to create a small button with three dots on it, like we
i want set width for PdfpCell in Table, i want design this i Write
i want set some fields, like updateDate, createDate and deleteDate, for each my entities,
I want set different access for different modules. I tried out $this->allow($role, $module, $controller,
I want set a border to Relativelayout. I make relativelayout clickable and use selector
I want set interfaceOrientation in one UIView as LandscapeLeft and Portrait in other UIView.
i want set the visibility to itemized overlay in map view. if the zoom
I want set Listbox background to transparent but not working Is there any idea?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.