This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript 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
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How to drag my last card images witch is draw on applet.

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please help me , how can I drag my last card images witch is draw on applet.

I have draw 83 images one by one on applet , now I want to drag the only last images in the bunch of card, I am dragging all images one by one and drop it, but I want to only drag one card images witch is on top, please help me ASAP.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have 26 replies here, do you really want to repeat all that?

http://www.java-forums.org/java-applets/58956-how-drage-my-card-images-draw-applet.html

I haven't read through all of those, so this might be a repeat,
simplest way might be to load your images into JLabels, add
mouse and motion listeners to the labels, add the labels on
top of each other, then drag the top one.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am also working on a card-based app. Mine is for getting knowledgeable about Java.

One thing that I suggest is that you look into the JLayeredPane if you haven't already done so:
http://docs.oracle.com/javase/tutorial/uiswing/components/layeredpane.html

When I started my game I was unaware of this class, and when I discovered it it made things so much easier. It's an extremely powerful control with an API that is surprisingly intuitive.

I forget if the demo in that uses true drag and drop or handling mouse events for moving the little Duke guy around, but in mine I used the mouse listeners like Michael Dunn suggested. I also created a "Card" class that uses JLabel as its parent.

 
Ganesh Gothi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Steve Stevenson,
Please show me demo in that uses true drag and drop or handling mouse events for moving the little Duke guy around, because I am working on drag and drop of images, I am making game like a rummy card game and using applet in my web application, so please give me the or show me the demo, those you saying in post.
 
Steve Stevenson
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ganesh Gothi wrote: Hi Steve Stevenson,
Please show me demo in that uses true drag and drop or handling mouse events for moving the little Duke guy around, because I am working on drag and drop of images, I am making game like a rummy card game and using applet in my web application, so please give me the or show me the demo, those you saying in post.



It's actually inside that link, but this direct link ought to open up the app so that you can see it in action:

http://docs.oracle.com/javase/tutorialJWS/uiswing/components/ex6/LayeredPaneDemo.jnlp


The article itself from my other post up above describes how it works.
 
He was giving me directions and I was powerless to resist. I cannot resist this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic