This button will only appear if you move your mouse over it. See here:
http://mitch9654.zymichost.com/Java/index.html
You hava to move the mouse around the top left
my applet is this
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Main;
import java.applet.Applet;
import Buttons.AddButton;
import java.awt.*;
import java.awt.event.*;
/**
*
* @author Mitch
*/
public class Main extends Applet {
boolean firstrun = true;
AddButton add;
buttonhandler addlistener;
@Override
public void init() {
setLayout(null);
addlistener = new buttonhandler();
add = new AddButton("AddSongs", 0, 0, 40, 40);
add.setBounds(50, 90, 40, 40);
repaint(50, 90, 40, 40);
add(add);
add.addActionListener(addlistener);
}
@Override
public void paint(Graphics g) {
resize(200, 200);
}
private static class buttonhandler implements ActionListener {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
}
}
My button is this:
package Buttons;
import java.awt.*;
import javax.swing.JButton;
/**
*
* @author Mitch
*/
public class AddButton extends JButton {
Color background;
Color cross;
int inx;
int iny;
int width;
int height;
public AddButton(String label, int inxtemp, int inytemp, int widthtemp, int heighttemp) {
super(label);
inx = inxtemp;
iny = inytemp;
width = widthtemp;
height = heighttemp;
System.out.println("Hi");
repaint(inx, iny, width, height);
System.out.println("bye");
}
@Override
protected void paintComponent(Graphics g) {
System.out.println("Beginning");
System.out.println(inx);
System.out.println(iny);
System.out.println(width);
System.out.println(height);
g.setColor(Color.BLACK);
g.drawRect(inx, iny, width, height);
resize(width, height);
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;
}
}