code
import java.awt.*;
import javax.swing.*;
import java.awt.geom.*;
public class QuestionA extends JApplet
{
public void init()
{
PanelLukis panel = new PanelLukis(this);
getContentPane().add(panel);
}
}
class PanelLukis extends JPanel
{
private int x_axis, y_axis;
private int squareWidth, squareHeight;
private int x, y, coordinateX, coordinateY, squareNo;
JApplet app;
public PanelLukis(JApplet a)
{
app = a;
app.setBackground(Color.white);
}
public void paintComponent(Graphics g)
{
x_axis = getWidth();
y_axis = getHeight();
squareWidth = 50;
squareHeight = 50;
Graphics2D graphic2d = (Graphics2D) g;
y = (y_axis -300) / 2;
for(int j = 0; j <= 5; j++)
{
x = (x_axis -300) / 2;
for(int i = 0; i <= 5; i++)
{
Rectangle2D.Double square = new Rectangle2D.Double(x, y, squareWidth, squareHeight);
graphic2d.draw(square);
x += squareWidth;
}
y += squareHeight;
}
}
}
this is the board for the game
import java.awt.*;
import javax.swing.*;
public class blue extends JApplet
{
public void paint (Graphics g)
{
g.setColor(Color.blue);
g.fillOval(0,0,40,40);
}
}
this is the blue ball
import java.awt.*;
import javax.swing.*;
public class yellow extends JApplet
{
public void paint (Graphics g)
{
g.setColor(Color.yellow);
g.fillOval(0,0,40,40);
}
}
this is yellow ball
import java.awt.*;
import javax.swing.*;
public class red extends JApplet
{
public void paint (Graphics g)
{
g.setColor(Color.red);
g.fillOval(0,0,40,40);
}
}
this is red ball
i need help in this programming..
i want to make this game similar like this http://www.geekin.de/data/public/umsetzung/five_or_more/ or like tic-tac-toe..
anyone can help me..
this is my final year project.
i don't know how to integrate the ball and the board to appear in randomly. (",)