你可參考:;word=java%CF%F3%C6%E5%B5%C7%C2%BC%BD%E7%C3%E6%B5%C4%B4%FA%C2%EB
成都創(chuàng)新互聯(lián)是一家專(zhuān)業(yè)提供浦東企業(yè)網(wǎng)站建設(shè),專(zhuān)注與做網(wǎng)站、成都網(wǎng)站設(shè)計(jì)、H5開(kāi)發(fā)、小程序制作等業(yè)務(wù)。10年已為浦東眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專(zhuān)業(yè)網(wǎng)站建設(shè)公司優(yōu)惠進(jìn)行中。
還有這個(gè);
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("隸書(shū)", Font.PLAIN, 24));
jLabel3.setText("學(xué) 生 考 試 系 統(tǒng)");
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;
//判斷權(quán)限的方法
public void success()
{
try{
ResultSet rs1;
String s1="select * from 管理權(quán)限 where name='"+jTextField1.getText()+"' and password='"+jPasswordField1.getText()+"'";
rs1=sqlcx.Rs_jiluji(s1);
rs1.first();
sum=Integer.parseInt((String)(rs1.getString(3)));
System.out.println(sum);
very();
}
catch(Exception c)
}
//根據(jù)權(quán)限設(shè)置窗口
public void very()
{
if (sum==1)
{JOptionPane.showOptionDialog(this, "您現(xiàn)在是以教師權(quán)限登陸", "登陸信息"
, JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE,
null, null, null);
}
else
{
JOptionPane.showOptionDialog(this, "你現(xiàn)在是以學(xué)生權(quán)限登陸", "登陸信息"
, JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE,
null, null, null);
wo.jButton2.setVisible(false);
wo.jButton3.setVisible(false);
wo.jButton4.setVisible(false);
wo.jButton5.setVisible(false);
wo.jButton6.setVisible(false);
wo.jButton7.setVisible(false);
wo.jButton8.setVisible(false);
wo.jMenu2.setVisible(false);
wo.jMenu3.setVisible(false);
wo.jMenu4.setVisible(false);
}
}
public void jButton1_actionPerformed(ActionEvent e)
{
//判斷用戶名是否為空
if (jTextField1.getText().length() == 0) {
JOptionPane.showOptionDialog(this, "用戶名不能為空", "錯(cuò)誤信息"
, JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE,
null, null, null);
}
//判斷密碼是否為空
else if (jPasswordField1.getText().length()==0)
{
JOptionPane.showOptionDialog(this,"密碼不能為空", "錯(cuò)誤信息"
, JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE,
null, null, null);
}
else
{
try
{
ResultSet rs;//聲明記錄集
String sql="select * from 管理權(quán)限 where name='"+jTextField1.getText()+"'";
rs = sqlcx.Rs_jiluji(sql);
if (rs.next())
{
if(jPasswordField1.getText().equals(rs.getString(2)))
{
success();
wo.setBounds(60,40,700,600);
wo.setVisible(true);
this.dispose();
}
else
{
JOptionPane.showOptionDialog(this,"密碼錯(cuò)誤", "錯(cuò)誤信息"
, JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE,
null, null, null);
}
}
else
{
JOptionPane.showOptionDialog(this,"沒(méi)有所要找的用戶名", "錯(cuò)誤信息"
, JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE,
null, null, null);
}
}
catch(Exception c){
JOptionPane.showOptionDialog(this,"連接數(shù)據(jù)庫(kù)失敗", "錯(cuò)誤信息"
, JOptionPane.DEFAULT_OPTION,
JOptionPane.ERROR_MESSAGE,
null, null, null);
}
}
}
public void jButton2_actionPerformed(ActionEvent e) {
System.exit(0);
}
}
import java.awt.*;
import javax.swing.*;
public class Chessboard extends JApplet {
int baseXPosition, baseYPosition;
int currentXPosition, currentYPosition;
public void init() {
baseXPosition = 40; // 棋盤(pán)的開(kāi)始x位置
baseYPosition = 40; // 棋盤(pán)的開(kāi)始y位置
setBackground(Color.black); // 設(shè)置背景顏色黑色
}
public void paint(Graphics g) { // 繪制棋盤(pán)
currentXPosition = baseXPosition; // currentXPosition當(dāng)前的x位置
currentYPosition = baseYPosition; // currentYPosition當(dāng)前的y位置
for (int row = 0; row 8; row++) {
currentXPosition = baseXPosition + row * 40;
for (int column = 0; column 8; column++) {
if ((column + row) % 2 == 0)
g.setColor(Color.white); // 設(shè)置棋盤(pán)格子的顏色
else
g.setColor(Color.red); // 設(shè)置棋盤(pán)格子的顏色
currentYPosition = baseXPosition + column * 40;
g.drawRect(currentXPosition,currentYPosition,40,40);//;代碼4 //在當(dāng)前位置繪制棋盤(pán)的格子;每個(gè)格子的大小是40*40像
g.fillRect(currentXPosition,currentYPosition,40,40);
}
}
}
}
import java.awt.Color;
import javax.swing.*;
public class Chess extends JPanel
{// 繼承面板類(lèi)
public Chess(int grids,int gridsize)
{//grids:行數(shù)和列數(shù), gridsize:單元格的高和寬
super(null);
for(int i=0; igrids; i++)
{
for(int j=0; jgrids; j++)
{
JLabel l = new JLabel();//生成標(biāo)簽實(shí)例
l.setSize(gridsize,gridsize);
l.setLocation(i*gridsize,j*gridsize);
if((i+j)%2==0)
{ //當(dāng)小方格的坐標(biāo)和剛好是偶數(shù)時(shí),
l.setBackground(Color.black); //設(shè)置為方格為黑色
l.setOpaque(true); //設(shè)置為不透明
}
l.setBorder(BorderFactory.createLineBorder(Color.black)); //設(shè)置邊界為黑色
add(l);//將l標(biāo)簽添加到面板
}
}
}
public static void main(String[] args)
{
JFrame f = new JFrame();
f.setSize(658,677); //邊框的長(zhǎng)和寬
f.setLocationRelativeTo(null); //設(shè)置窗口相對(duì)于指定組件的位置
f.add(new Chess(8,80));
f.setVisible(true);
}
}
當(dāng)前題目:java象棋源代碼 java中國(guó)象棋源碼
本文鏈接:http://www.rwnh.cn/article44/ddcpjee.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供用戶體驗(yàn)、定制開(kāi)發(fā)、外貿(mào)網(wǎng)站建設(shè)、面包屑導(dǎo)航、全網(wǎng)營(yíng)銷(xiāo)推廣、ChatGPT
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)