Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Making Palette

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi..
How can I make a palette that contains some shapes so I can drag - drop those shapes to a drawing area?
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One way you could do this is with a glass pane set over your JRootPane on you top–level container. When you start dragging the shape from the origin panel you could set the glass pane visible and draw/drag the shape on the glass pane (possibly removing it from the origin component). When you drop the shape over the destination component (mouseReleased) you can set the glass pane invisible and draw the shape on the destination component. You could remove the shape from the origin component after the drop onto destination or at the initial drag. You would need MouseInputAdapters for both the origin component and glass pane component. The Swing tutorial has a glass pane demonstration example with useful suggestions found on How to Use Root Panes.
 
He was expelled for perverse baking experiments. This tiny ad is a model student:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic