|
Ok, I am very grateful for all the replies, but im basically retarded. I dont understand how to use the JPanel, I have messed with it in the past, but never got it to do what I wanted. This is what I have and I'm trying to create connect for in a simple way, nothing fancy. I am a complete noob and am doing extremely poor in my Java class. You guys will probably think I'm mentally ill after looking at this code, but this is what I got so far. Like I said earlier, I just want the mouseclick to change a circle's color. I'm trying to just get one circle to change right now so I know how to setup the rest. I'm sorry that I can't understand what you guys are trying to teach me to do. Thanks for the help you have given me and any more yet to come.
import java.awt.event.MouseAdapter;
import java.awt.event.*;
import java.awt.geom.*;
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import java.awt.*;
import java.applet.*;
public class Connect4 extends Applet implements MouseListener{
int x = 405;
int y = 70;
int z = 70;
int u = 70;
// Shape circleShape = new Ellipse2D.Double(x,y,z,u);
public void init() {
// circleshape.addMouseListener;
addMouseListener(this);
;
}
public void paint(Graphics g)
{
Shape circleShape = new Ellipse2D.Double(x,y,z,u);
Graphics2D ga = (Graphics2D)g;
g.setColor(Color.yellow);
g.fillRect(300,60,600,500);
g.setColor(Color.white);
g.fillOval(325,70,70,70);
g.fillOval(325,150,70,70);
g.fillOval(325,230,70,70);
g.fillOval(325,310,70,70);
g.fillOval(325,390,70,70);
g.fillOval(325,470,70,70);
ga.fill(circleShape);
ga.draw(circleShape);
//g.fillOval(405,70,70,70);
g.fillOval(405,150,70,70);
g.fillOval(405,230,70,70);
g.fillOval(405,310,70,70);
g.fillOval(405,390,70,70);
g.fillOval(405,470,70,70);
g.fillOval(485,70,70,70);
g.fillOval(485,150,70,70);
g.fillOval(485,230,70,70);
g.fillOval(485,310,70,70);
g.fillOval(485,390,70,70);
g.fillOval(485,470,70,70);
g.fillOval(565,70,70,70);
g.fillOval(565,150,70,70);
g.fillOval(565,230,70,70);
g.fillOval(565,310,70,70);
g.fillOval(565,390,70,70);
g.fillOval(565,470,70,70);
g.fillOval(645,70,70,70);
g.fillOval(645,150,70,70);
g.fillOval(645,230,70,70);
g.fillOval(645,310,70,70);
g.fillOval(645,390,70,70);
g.fillOval(645,470,70,70);
g.fillOval(725,70,70,70);
g.fillOval(725,150,70,70);
g.fillOval(725,230,70,70);
g.fillOval(725,310,70,70);
g.fillOval(725,390,70,70);
g.fillOval(725,470,70,70);
g.fillOval(805,70,70,70);
g.fillOval(805,150,70,70);
g.fillOval(805,230,70,70);
g.fillOval(805,310,70,70);
g.fillOval(805,390,70,70);
g.fillOval(805,470,70,70);
}
public void mouseClicked(MouseEvent e)
{
/*circleShape = new Ellipse2D.Double(x,y,z,u);
Graphics2D ga = (Graphics2D)g;
ga.setColor(Color.blue);
ga.fill(circleShape);
x = 395;
y = 70;
z = 70;
u = 70;*/
repaint();
}
public void mouseReleased(MouseEvent e) {}
public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e){}
public void mousePressed(MouseEvent e){ }
}
|