• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

paintDragPreview(...) method needs work

 
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,

I'm kinda stuck on a problem involving a whiteboard project. The project has a class named PaintableShape which wraps Shape objects. When I select a Shape object on the Whiteboard I can drag it to another location, and while doing so, provide the user with a painted preview of the shape as the mouse moves the shape across the whiteboard by calling the method paintDragPreview(Graphics2D g).

I've recently introduced the ability to also wrap components into PaintableShape as is evident by the additional constructor you see in the code below. The only difference is that components are actually set on the WhiteBoard (which extends JPanel) via an XYLayoutManager. There will potentially be only two types of components, both of which are rectangularly shaped. So I created a static instance variable for now to represent any component that may be on the whiteboard. Since the code in the method for paintDragPreview(...) works great for Shape objects, for some reason, I'm not getting the rectangle being drawn when I attempt to drag a component across the whiteboard.

Can someone lend there vast experience on this problem and help me to get this method working for components?

Thanks,

Alan


 
Anderson gave himself the promotion. So I gave myself this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic