import java.awt.*;
import javax.swing.*;
public class JazzaChess extends JFrame {
private JPanel mainPanel;
private DrawingPanel drawPanel;
static SamChess myChessBoard;
private int x = 100, y = 60;
public JazzaChess() {
super("CHESS BOARD AND CHESS PIECES");
mainPanel = new JPanel();
mainPanel.setLayout(null);
mainPanel.setBackground(Color.RED);
drawPanel= new DrawingPanel();
drawPanel.setBounds(mainPanel.getWidth() / 2, mainPanel.getHeight() / 2, 1000, 1000);
drawPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 5));
mainPanel.add(drawPanel, BorderLayout.CENTER);
setContentPane(mainPanel);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(1000,700);
setLocationRelativeTo(null);
setVisible(true);
}
public static void main(String[] args) {
myChessBoard = new SamChess();
}
class DrawingPanel extends JPanel {
private int x = 100, y = 60;
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
drawingMethod(g2d);
}
private void drawingMethod(Graphics2D g2d) {
for (int i = 0; i <= 8; ++i) {
g2d.drawLine(x, (y * i) + 60, x + 800, (y * i) + 60);
// g2d.drawLine((x * j) + 100, y, (x * j) + 100, y + 480);
}
for (int j = 0; j <= 8; ++j) {
g2d.drawLine((x * j) + 100, y, (x * j) + 100, y + 480);
}
g2d.setColor(Color.RED);
g2d.fillRect(200, 60, 100, 60);
ImageIcon myImage3 = new ImageIcon("c:\\Chesspieces\\chess2.png");
Image picImage3 = myImage3.getImage();
g2d.drawImage(picImage3,130,65, this);
ImageIcon myImage = new ImageIcon("c:\\Chesspieces\\chess1.png");
Image picImage = myImage.getImage();
g2d.drawImage(picImage, 230,65, this);
ImageIcon myImage6 = new ImageIcon("c:\\Chesspieces\\chess3.png");
Image picImage6 = myImage6.getImage();
g2d.drawImage(picImage6, 330,65, this);
g2d.fillRect(400, 60, 100, 60);
ImageIcon myImage8 = new ImageIcon("c:\\Chesspieces\\chess5.png");
Image picImage8 = myImage8.getImage();
g2d.drawImage(picImage8, 430,61, this);
ImageIcon myImage9 = new ImageIcon("c:\\Chesspieces\\chess2.png");
Image picImage9 = myImage9.getImage();
g2d.fillRect(100, 120, 100, 60);
g2d.fillRect(300, 120, 100, 60);
g2d.fillRect(500, 120, 100, 60);
g2d.fillRect(700, 120, 100, 60);
g2d.drawImage(picImage9, 130,125, this);
g2d.drawImage(picImage9, 230,125, this);
g2d.drawImage(picImage9, 330,125, this);
g2d.drawImage(picImage9, 430,125, this);
g2d.drawImage(picImage9, 530,125, this);
g2d.drawImage(picImage9, 630,125, this);
g2d.drawImage(picImage9, 730,125, this);
g2d.drawImage(picImage9, 830,125, this);
g2d.fillRect(200, 180, 100, 60);
g2d.fillRect(400, 180, 100, 60);
g2d.fillRect(600, 180, 100, 60);
g2d.fillRect(800, 180, 100, 60);
g2d.fillRect(100, 240, 100, 60);
g2d.fillRect(300, 240, 100, 60);
g2d.fillRect(500, 240, 100, 60);
g2d.fillRect(700, 240, 100, 60);
g2d.fillRect(200, 300, 100, 60);
g2d.fillRect(400, 300, 100, 60);
g2d.fillRect(600, 300, 100, 60);
g2d.fillRect(800, 300, 100, 60);
g2d.fillRect(100, 360, 100, 60);
g2d.fillRect(300, 360, 100, 60);
g2d.fillRect(500, 360, 100, 60);
g2d.fillRect(700, 360, 100, 60);
g2d.fillRect(800, 60, 100, 60);
ImageIcon myImage4 = new ImageIcon("c:\\Chesspieces\\chess2.png");
Image picImage4 = myImage4.getImage();
g2d.drawImage(picImage4, 830,65, this);
ImageIcon myImage2 = new ImageIcon("c:\\Chesspieces\\chess1.png");
Image picImage2 = myImage2.getImage();
g2d.drawImage(picImage2,730,65, this);
g2d.fillRect(600, 60, 100, 60);
ImageIcon myImage5 = new ImageIcon("c:\\Chesspieces\\chess3.png");
Image picImage5 = myImage5.getImage();
g2d.drawImage(picImage5, 630,65, this);
ImageIcon myImage7 = new ImageIcon("c:\\Chesspieces\\chess4.png");
Image picImage7 = myImage7.getImage();
g2d.drawImage(picImage7, 530,61, this);
ImageIcon myImage17 = new ImageIcon("c:\\Chesspieces\\chess6.png");
Image picImage17 = myImage17.getImage();
g2d.drawImage(picImage17,130,428, this);
g2d.fillRect(200, 420, 100, 60);
g2d.fillRect(400, 420, 100, 60);
g2d.fillRect(600, 420, 100, 60);
g2d.fillRect(800, 420, 100, 60);
g2d.fillRect(100, 480, 100, 60);
g2d.drawImage(picImage17,230,428, this);
g2d.drawImage(picImage17,330,428, this);
g2d.drawImage(picImage17,430,428, this);
g2d.drawImage(picImage17,530,428, this);
g2d.drawImage(picImage17,630,428, this);
g2d.drawImage(picImage17,730,428, this);
g2d.drawImage(picImage17,830,428, this);
g2d.drawImage(picImage17,130,486, this);
ImageIcon myImage28 = new ImageIcon("c:\\Chesspieces\\chess7.png");
Image picImage28 = myImage28.getImage();
g2d.drawImage(picImage28,230,486, this);
g2d.fillRect(300, 480, 100, 60);
ImageIcon myImage29 = new ImageIcon("c:\\Chesspieces\\chess8.png");
Image picImage29 = myImage29.getImage();
g2d.drawImage(picImage29,330,486, this);
ImageIcon myImage25 = new ImageIcon("c:\\Chesspieces\\chess6.png");
Image picImage25 = myImage25.getImage();
g2d.drawImage(picImage25,830,486, this);
g2d.fillRect(700, 480, 100, 60);
ImageIcon myImage27 = new ImageIcon("c:\\Chesspieces\\chess7.png");
Image picImage27 = myImage27.getImage();
g2d.drawImage(picImage27,730,486, this);
ImageIcon myImage30 = new ImageIcon("c:\\Chesspieces\\chess8.png");
Image picImage30 = myImage30.getImage();
g2d.drawImage(picImage30,630,486, this);
g2d.fillRect(500, 480, 100, 60);
ImageIcon myImage31 = new ImageIcon("c:\\Chesspieces\\chess9.png");
Image picImage31 = myImage31.getImage();
g2d.drawImage(picImage31,530,480, this);
ImageIcon myImage32 = new ImageIcon("c:\\Chesspieces\\chess10.png");
Image picImage32 = myImage32.getImage();
g2d.drawImage(picImage32,430,480, this);
}
}
}