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 8580287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:47:47+00:00 2026-06-11T20:47:47+00:00

Using the Graphics class and a panel, I can draw a geometric shape onto

  • 0

Using the Graphics class and a panel, I can draw a geometric shape onto a Form. I understood that i cannot apply events to this shape (like click, drag etc.).

How can i create a geometric shape (perhaps using Points) to which I can apply events, for instance to allow the shape to be moved by dragging and dropping?

  • 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-11T20:47:49+00:00Added an answer on June 11, 2026 at 8:47 pm

    If you attach event handlers directly to the Panel on which you are drawing these shapes, you can use them to determine where the user is hovering the mouse, where they clicked, if they’re dragging, etc. You can determine if the user is clicking on a vertex of points (perhaps allowing them to change the shape) or within a set of points defining a polygon (perhaps allowing them to move it). You can then make the necessary changes to an array of Points defining that shape based on the user’s mouse “gestures”, that are then used to redraw the shape on the next window Paint().

    As a succinct answer to “how can I know which shape was clicked”, implement a “point in polygon” test; given a set of points defining a polygon M and a point P which may or may not be inside M, find a point Q guaranteed to be outside the shape you want to test, draw an imaginary line PQ between P and Q, and count how many line segments of M that PQ crosses. If that number is odd, P lies within M.

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

Sidebar

Related Questions

I can't get graphics/text to draw on my panel/canvas/window in my Java program (using
Using core graphics , I am trying to draw a line, in that when
I resized the picture into 100x100 size by using Graphics class and drawImage() method.
I resized an image using Java2D Graphics class. But it doesn't look right. BufferedImage
I want to draw string using Graphics with Rectangle border outside the string. This
I have a program that draws some vector graphics using System.Drawing and the Graphics
Say I have a line drawn with several edges using Shape.graphics' moveTo() and lineTo()
I try to draw rain and snow as particle system using Core Graphics .
I have a problem making an inner class that extends from JPanel to draw
Question: How do i draw a rectangle on a Panel, rather than a form.

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.