How would I make an Image work like a button? I need it for a yahtzee game.
I want it so that after i roll the die and the image is displayed i want to be able to select the die i wish to keep and then re-roll the ones i didnt keep.
Translucentbill
0
Newbie Poster
Recommended Answers
Jump to Postimport java.awt.*; import javax.swing.*; import java.awt.event.*; class ImagesClicking implements MouseListener{ public static void main(String[] args){ new ImagesClicking(); } public ImagesClicking(){ Image image = new ImageIcon("").getImage(); //or whatever way you get your image. image.addMouseListener(this); } public void MouseClicked(MouseEvent e){ int ClickedCount = e.getClickedCount(); if(ClickCount > 0){ //Stuff to …
Jump to PostOh, someone was seemingly unhappy that they didn't get cut-n-paste code. Well, I'm sorry. You are the one asking the question, you are the one that should make the effort. Look at the API docs, the tutorials and Google. If you can't figure it out come back. I gave you …
Jump to PostSorry? I was just giving him an example.
All 10 Replies
masijade
1,351
Industrious Poster
Team Colleague
Featured Poster
mangopearapples
16
Posting Whiz in Training
masijade
1,351
Industrious Poster
Team Colleague
Featured Poster
mangopearapples
16
Posting Whiz in Training
Akill10
96
Posting Pro
mangopearapples
16
Posting Whiz in Training
masijade
1,351
Industrious Poster
Team Colleague
Featured Poster
goodtaste
0
Junior Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
goodtaste
0
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.