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

  • Home
  • SEARCH
  • 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 3442956
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:43:57+00:00 2026-05-18T08:43:57+00:00

Hi I have a UI which has a panel and you can use your

  • 0

Hi
I have a UI which has a panel and you can use your mouse for puting some points on it and it is its code:

    double x = evt.getX();
    double y = evt.getY() + 20;
    Graphics g = getGraphics();
    g.setColor(Color.black);
    g.fillOval((int) x, (int) y, 10, 10);
    Point point = new Point(x, y);
    pointList.add(point);

as you see my “x” field and “y” field has double type but when i print those points ,their value will be int ,how can i keep their value and use them in my functions with double type.
when I print them :

[120.0 ,134.0]
[345.0,785.0]
  • 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-05-18T08:43:58+00:00Added an answer on May 18, 2026 at 8:43 am

    The positions on the panel are always going to be integers, because that’s what getX and getY return. You can’t click on half a pixel. 😉

    What you have stored is actually a double. That’s why it says “120.0” rather than just “120”. If you store an integer into a floating point type (like a double), then it gets stored as the floating point equivalent of that integer (which is the same as putting “.0” at the end). Because the value you are storing into it will always be an integer, you’re always going to end up with a whole number in your doubles (unless you do some other mathematical processing on them which causes them to change)

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

Sidebar

Related Questions

I have some JavaScript code and a button which already has an event/action assigned
I have an aspx page which has a GridView and a Panel with Summary
I have some folders in my server where i have several scripts which use
I have a composite which extends ResizeComposite and has a DockLayoutPanel as its root.
I have a panel xib which is owned by class FooController. FooController also has
I have an MVC app in Extjs 4 which has a View (extending Ext.panel.Panel
I have list of some data items. Each has a method GetStyle which returns
I have an AJAX application which has used CSS divs to create panels on
I have DataSet which has 3 columns. Name - insurance comp. name - treatmentDate
I have ControlA which accepts an IInterfaceB which has a property of type List<unknownType>

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.