象棋源代码java 象棋的编程代码公开

显示一个国际象棋棋盘的java源代码import java.awt.Color;
import javax.swing.*;
public class Chess extends JPanel
{// 继承面板类
public Chess(int grids,int gridsize)
{//grids:行数和列数, gridsize:单元格象棋源代码java的高和宽
super(null);
for(int i=0; igrids; i++)
{
for(int j=0; jgrids; j++)
{
JLabel l = new JLabel();//生成标签实例
l.setSize(gridsize,gridsize);
l.setLocation(i*gridsize,j*gridsize);
if((i+j)%2==0)
{//当小方格象棋源代码java的坐标和刚好是偶数时象棋源代码java,
l.setBackground(Color.black);//设置为方格为黑色
l.setOpaque(true);//设置为不透明
}
l.setBorder(BorderFactory.createLineBorder(Color.black));//设置边界为黑色
add(l);//将l标签添加到面板
}
}
}
public static void main(String[] args)
{
JFrame f = new JFrame();
f.setSize(658,677);//边框象棋源代码java的长和宽
f.setLocationRelativeTo(null);//设置窗口相对于指定组件象棋源代码java的位置
f.add(new Chess(8,80));
f.setVisible(true);
}
}
java象棋登录界面的代码象棋源代码java你可参考:;word=java%CF%F3%C6%E5%B5%C7%C2%BC%BD%E7%C3%E6%B5%C4%B4%FA%C2%EB
还有这个;
package java1;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.Rectangle;
import java.awt.Font;
public class login extends JFrame
{
public login() {
try {
jbInit();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
public static void main(String[] args)
{
login frm=new login();
frm.setBounds(300,200,300,260);
frm.setVisible(true);
}
private void jbInit() throws Exception {
this.getContentPane().setLayout(null);
jLabel1.setForeground(Color.red);
jLabel1.setText("用户名");
jLabel1.setBounds(new Rectangle(25, 72, 68, 29));
jButton2.setBounds(new Rectangle(142, 159, 81, 30));
jButton2.setText("取消");
jButton2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton2_actionPerformed(e);
}
});
jButton1.setBounds(new Rectangle(38, 159, 81, 29));
jButton1.setText("确定");
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton1_actionPerformed(e);
}
});
jTextField1.setBounds(new Rectangle(109, 79, 136, 23));
jPasswordField1.setBounds(new Rectangle(109, 115, 136, 23));
this.getContentPane().add(jLabel1);
jLabel3.setFont(new java.awt.Font("隶书", Font.PLAIN, 24));
jLabel3.setText("学 生 考 试 系 统");
jLabel3.setBounds(new Rectangle(22, 15, 268, 47));
this.getContentPane().add(jTextField1);
this.getContentPane().add(jLabel2);
this.getContentPane().add(jButton2);
this.getContentPane().add(jButton1);
this.getContentPane().add(jLabel3);
this.getContentPane().add(jPasswordField1);
jLabel2.setForeground(Color.red);
jLabel2.setText("密码");
jLabel2.setBounds(new Rectangle(26, 112, 68, 29));
}
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JTextField jTextField1 = new JTextField();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JLabel jLabel3 = new JLabel();
JPasswordField jPasswordField1 = new JPasswordField();
main2 wo=new main2();
int sum;
//判断权限象棋源代码java的方法
public void success()
{
try{
ResultSet rs1;
String s1="select * from 管理权限 where name='"+jTextField1.getText()+"' and password='"+jPasswordField1.getText()+"'";

推荐阅读