• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Java GUI question

NTB

Diamond Member
pardon the brainfart, but I cannot think of a good way to do this: I am trying to write a simple cardgame program, and so far I have a working deck of cards. However, to do anything with them, I have to push buttons. for dealing this isn't a problem, but for holding / discarding and stuff like that, I would like to make the cards clickable - I would eventually like to transfer what I've done as far as making the deck goes over to a solitaire-type game. Any ideas?

It's probably something obvious, but I'm drawing a blank 😛

Nate
 
I haven't touched Java for more than a year, but I think you'll need to implement an ActionListener to listen to a mouse click event?

Might be completely wrong though 😀
 
Originally posted by: screw3d
I haven't touched Java for more than a year, but I think you'll need to implement an ActionListener to listen to a mouse click event?

Might be completely wrong though 😀

that's what I was thinking; what I'm trying to figure out is the best way to do it. I have a class which defines *what* a card is - Rank, Suit, and ain image file; individual cards are declared (as card objects) from this.

Nate
 


that looks exactly like what I need! too bad I have to pay to see it 🙁

edit: where'd the other links come from? you must've edited your post right as I clicked on the thread.
and another edit: thanks for the other links! I will look into the mouse-listener. I knew about using a button already; I was just curious about other ways to do it.

Nate
 
Back
Top