Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How can I drag a JComponent?  RSS feed

 
Yogesh Kodgule
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all!

I am extending the JComponent and making my own component.

I wan't this component to be dragged. How can I do that?
To be more specific I am supposed to create a Toolbar and this component on it. I wan't it to be dragged to another panel and have an instance of it there.

Can you suggest some suitable ways for this? What APIs shall be helpful?

Any kind of help is appreciated.

Yogesh :roll:
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are a number of ways to do this. Working with the Drag and Drop trail in the java tutorial is one way. You could add your mouse listeners directly to the JToolBar components and to the target drop panel(s). You could use a glass pane or an OverlayLayout with a non–opaque top panel for your mouse listeners. This example app uses the last option.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!