• Post Reply Bookmark Topic Watch Topic
  • New Topic

Making Palette  RSS feed

 
abu alfouz
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • 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?
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!