The reason why the border is not displayed could be because the draw method of the Chess class does not include drawing the border. You can modify the draw method of the Chess class to include drawing the border.

Here's an example of how you can modify the draw method to include the border:

public void draw(Graphics g) {
    g.drawImage(image, point.x, point.y, null);
    g.setColor(Color.red); // Change the color to the color you want for the border
    g.drawRect(point.x, point.y, Constant.shiftingX, Constant.shiftingX); // Draw the border
}

By adding the g.drawRect method, you can draw a border around each chess piece. Make sure to replace Color.red with the color you want for the border.

Additionally, make sure that the drawChess method in the selectedChess object also includes the g.drawRect method to draw the border when the chess piece is selected

Chess allChess = new Chess109; 	Chess selectedChess = null;当前选中的棋子默认为null 	boolean isSide = true;默认红方开始 	Override 	public void paintGraphics g 设置图片 		gdrawImageImagesgetImageConstantBg 0 0 null; 		gd

原文地址: https://www.cveoy.top/t/topic/irUm 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录