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.

A MouseListener?

import 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 do when image is clicked
        }
    }
}

Oh, 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 the classname you need to research, so research it. That is one of the major responsibilities for a developer.

Sorry? I was just giving him an example.

Sorry? I was just giving him an example.

He was referring to the negative feedback he received, nothing about you. But, you just basically gave the guy cut and paste code.
If he just googled mouse listener, from masijades post, he would have had to learn what a mouse listener is, how to use it etc. Hopefully the guy is intelligent enough to realise this and study each part of your example so he fully understands it.

He was referring to the negative feedback he received, nothing about you.

Phew.:sweat: Wait, where did the negative feedback come from? A PM?
Anyway, I thought I was going to get in trouble with the Suns System Administrator then.

No. You're fine. I, actually, have no problem with your post. You only provided an outline anyway.

Let me interject a petition here. I'm just a latecomer, who was looking for a way to make a simple photo that I would post in my blog, clickable and linked to my Facebook page, driving people to it when clicked, and upon searching DaniWeb, I was brought here. I read all the posts, but I'm NOT a developer, just a simple blogger, who comes here to learn. Therefore, I would not want to be treated as if I was supposed to know how to send a rocket into space (be nice to me, I'm a lady, just explaining my level of knowledge to you, nothing more,) if you could be patient and spare a couple of tips with a person at my level, I'm all ears and gratitude!

Thank you much!

Hi goodtaste.
Please don't be worried about the tough replies that some people get when they expect us to do their homework for them. Firstly this isn't a "we do your homework" service, and secondly we assume that the teacher has set a project that the student should be able to tackle with a bit of effort.
There are lots of people here who will freely give their time to help you become the best programmer you can be.
Please start a new thread for your question, and take a moment to explain that it is not a homework assignment, and let us know what your current level of skill/knowledge is. I'm sure you will get loads of help to devlop your skills so you can tackle this problem (and others like it).

Thank you so much, JamesCherrill! I got a bit intimidated when I read the thread, but I understand it now. I will start a new thread. You guys are the best!

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.