My custom button thing isn't clickable. I don't know why! (obviously :P)
I DO have an action listener

This make a button that looks like a cross. The input is:

"name", g, 0, 0, 100, 100

It looks like this: http://mitch9654.zymichost.com/Java/index.html

package Buttons;

import java.awt.*;
/**
 *
 * @author Mitch
 */
public class AddButton extends Button {
Color background;
Color cross;
    public AddButton(String label, Graphics g, int inx, int iny, int width, int height) {
        super(label);
        cross = new Color(200, 255, 200);
        background = new Color(0, 255, 0);
        g.setColor(background);
        g.fillRect(inx, iny, width, height);
        DrawCross(g, inx, iny, width, height, cross);
        g.setColor(Color.BLACK);
    }
    protected void DrawCross(Graphics g, int inx, int iny, int width, int height, Color cross) {
        int dimensionswidth[] = new int[3];
        int dimensionsheight[] = new int[3];
        int xc[] = new int[3];
        int yc[] = new int[3];
        dimensionswidth[0] = width / 3;
        dimensionsheight[0] = height / 3;
        dimensionswidth[1] = width / 3;
        dimensionsheight[1] = height / 3;
        dimensionswidth[2] = width / 3;
        dimensionsheight[2] = height / 3;
        xc[0] = inx;
        yc[0] = iny;
        xc[1] = width / 3 + xc[0];
        yc[1] = height / 3 + yc[0];
        xc[2] = width / 3 * 2 + xc[0];
        yc[2] = height / 3 * 2 + yc[0];
        if (width % 3 == 1) {
           dimensionswidth[2] += 1;
        }
        else if (width % 3 == 2) {
            dimensionswidth[1] += 1;
            dimensionswidth[2] += 1;
            xc[2] += 1;
        }
        if (height % 3 == 1) {
           dimensionsheight[2] += 1;
        }
        else if (height % 3 == 2) {
            dimensionsheight[1] += 1;
            dimensionsheight[2] += 1;
            yc[2] += 1;
        }
        g.setColor(cross);
        drawing:
        for(int x = 0; x < 3; x++) {
            for (int y = 0; y < 3; y++) {
              if ((x + y) % 2 == 1 || (x == 1 && y == 1)) {
                  g.fillRect(xc[x], yc[y], dimensionswidth[x], dimensionsheight[y]);
              }

            }
        }
    return;
    }
}

My custom button thing isn't clickable. I don't know why! (obviously :P)
I DO have an action listener

This make a button that looks like a cross. The input is:

"name", g, 0, 0, 100, 100

It looks like this: http://mitch9654.zymichost.com/Java/index.html

package Buttons;

import java.awt.*;
/**
 *
 * @author Mitch
 */
public class AddButton extends Button {
Color background;
Color cross;
    public AddButton(String label, Graphics g, int inx, int iny, int width, int height) {
        super(label);
        cross = new Color(200, 255, 200);
        background = new Color(0, 255, 0);
        g.setColor(background);
        g.fillRect(inx, iny, width, height);
        DrawCross(g, inx, iny, width, height, cross);
        g.setColor(Color.BLACK);
    }
    protected void DrawCross(Graphics g, int inx, int iny, int width, int height, Color cross) {
        int dimensionswidth[] = new int[3];
        int dimensionsheight[] = new int[3];
        int xc[] = new int[3];
        int yc[] = new int[3];
        dimensionswidth[0] = width / 3;
        dimensionsheight[0] = height / 3;
        dimensionswidth[1] = width / 3;
        dimensionsheight[1] = height / 3;
        dimensionswidth[2] = width / 3;
        dimensionsheight[2] = height / 3;
        xc[0] = inx;
        yc[0] = iny;
        xc[1] = width / 3 + xc[0];
        yc[1] = height / 3 + yc[0];
        xc[2] = width / 3 * 2 + xc[0];
        yc[2] = height / 3 * 2 + yc[0];
        if (width % 3 == 1) {
           dimensionswidth[2] += 1;
        }
        else if (width % 3 == 2) {
            dimensionswidth[1] += 1;
            dimensionswidth[2] += 1;
            xc[2] += 1;
        }
        if (height % 3 == 1) {
           dimensionsheight[2] += 1;
        }
        else if (height % 3 == 2) {
            dimensionsheight[1] += 1;
            dimensionsheight[2] += 1;
            yc[2] += 1;
        }
        g.setColor(cross);
        drawing:
        for(int x = 0; x < 3; x++) {
            for (int y = 0; y < 3; y++) {
              if ((x + y) % 2 == 1 || (x == 1 && y == 1)) {
                  g.fillRect(xc[x], yc[y], dimensionswidth[x], dimensionsheight[y]);
              }

            }
        }
    return;
    }
}

:edit

Oops, I forgot to add(); the button :P

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.