Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use Java to realize Chinese Chess Game

Shulou Source: shulou.com Published: 2022-05-31 18:14:48 10月03日 Update

This article introduces the relevant knowledge of "how to use Java to achieve Chinese chess games". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

I. Interface

The chess board should first be prepared, which is an interface of the right size, the right proportion and the right position, and then draw (yes, drawLine's) n lines and slashes on the form, the specific value is set according to the size of your interface. The interface drawn in this way is neat and looks good.

Public void paint (Graphics g) {super.paint (g); / / rewrite the drawing function Font f=new Font( "Microsoft Yahei", Font.BOLD,30); g.setFont (f); g.drawRect (60,50,500,560); / / Outer ring g.drawRect (70,60,480,540); / / Inner ring / / horizontal line part int length=60 For (int iTuno Bandi)

Tags: Pieces buttons movement function chessboard position array method interface background situation panel fit picture integer part chess one side two function Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Apple Shulou Technology Xiaomi macOS