蜘蛛牌

本文介绍了一个基于Java Swing的蜘蛛牌游戏实现,包括游戏界面设计、核心逻辑算法和难度选择等功能。通过窗口应用形式展现了蜘蛛牌游戏的玩法,并提供了不同难度级别的选项。
蜘蛛牌在朴克牌游戏当中是比较有趣的游戏,特别是闯关成功时刻,趣味无穷,本程序是给予窗口应用,及普通算法。

[img]http://dl.iteye.com/upload/attachment/293146/e2bb1360-fe48-3b36-9d55-c75958e51ba7.jpg[/img]

1、窗口面板控制台

package game;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;

public class Araneid extends JFrame
{

private static final long serialVersionUID = 1L;
public static final int EASY = 1;
public static final int NATURAL = 2;
public static final int HARD = 3;
private int grade = Araneid.EASY;
private Container pane = null;
private PKCard cards[] = new PKCard[104];
private JLabel clickLabel = null;
private int c = 0;
private int n = 0;
private int a = 0;
private int finish = 0;
Hashtable table = null;
private JLabel groundLabel[] = null;

public static void main(String[] args)
{
Araneid araneid = new Araneid();
}

/**
* This is the default constructor
*/
public Araneid()
{
super();
this.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
this.setSize(1024, 742);
this.setJMenuBar(new AraneidMenuBar(this));
this.pane = this.getContentPane();
this.pane.setBackground(new Color(0, 112, 26));
this.pane.setLayout(null);
this.clickLabel = new JLabel();
this.clickLabel.setBounds(883, 606, 121, 96);
this.pane.add(this.clickLabel);
this.clickLabel.addMouseListener(new MouseAdapter()
{
public void mouseReleased(MouseEvent me)
{
if (c < 60) Araneid.this.deal();
}
});
this.setTitle("蜘蛛牌");
this.initCards();
this.randomCards();
this.setCardsLocation();
groundLabel = new JLabel[10];
int x = 20;
for (int i = 0; i < 10; i++)
{
groundLabel[i] = new JLabel();
groundLabel[i]
.setBorder(javax.swing.BorderFactory
.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));
groundLabel[i].setBounds(x, 25, 71, 96);
x += 101;
this.pane.add(groundLabel[i]);
}
this.setVisible(true);
this.deal();
this.addKeyListener(new KeyAdapter()
{
class Show extends Thread
{
public void run()
{
Araneid.this.showEnableOperator();
}
}

public void keyPressed(KeyEvent e)
{
if (finish != 8) if (e.getKeyCode() == KeyEvent.VK_D && c < 60)
{
Araneid.this.deal();
}
else if (e.getKeyCode() == KeyEvent.VK_M)
{
new Show().start();
}
}
});
}

public void newGame()
{
this.randomCards();
this.setCardsLocation();
this.setGroundLabelZOrder();
this.deal();
}

public int getC()
{
return c;
}

public void setGrade(int grade)
{
this.grade = grade;
}

public void initCards()
{
if (cards[0] != null)
{
for (int i = 0; i < 104; i++)
{
pane.remove(cards[i]);
}
}
int n = 0;
if (this.grade == Araneid.EASY)
{
n = 1;
}
else if (this.grade == Araneid.NATURAL)
{
n = 2;
}
else
{
n = 4;
}
for (int i = 1; i <= 8; i++)
{
for (int j = 1; j <= 13; j++)
{
cards[(i - 1) * 13 + j - 1] = new PKCard((i % n + 1) + "-" + j,
this);
}
}
this.randomCards();
}

public void randomCards()
{
PKCard temp = null;
for (int i = 0; i < 52; i++)
{
int a = (int) (Math.random() * 104);
int b = (int) (Math.random() * 104);
temp = cards[a];
cards[a] = cards[b];
cards[b] = temp;
}
}

public void setNA()
{
a = 0;
n = 0;
}

public void setCardsLocation()
{
table = new Hashtable();
c = 0;
finish = 0;
n = 0;
a = 0;
int x = 883;
int y = 580;
for (int i = 0; i < 6; i++)
{
for (int j = 0; j < 10; j++)
{
int n = i * 10 + j;
pane.add(cards[n]);
cards[n].turnRear();
cards[n].moveto(new Point(x, y));
table.put(new Point(x, y), cards[n]);
}
x += 10;
}
x = 20;
y = 45;
for (int i = 10; i > 5; i--)
{
for (int j = 0; j < 10; j++)
{
int n = i * 10 + j;
if (n >= 104) continue;
pane.add(cards[n]);
cards[n].turnRear();
cards[n].moveto(new Point(x, y));
table.put(new Point(x, y), cards[n]);
x += 101;
}
x = 20;
y -= 5;
}
}

public void showEnableOperator()
{
int x = 0;
out: while (true)
{
Point point = null;
PKCard card = null;
do
{
if (point != null) n++;
point = this.getLastCardLocation(n);
while (point == null)
{
point = this.getLastCardLocation(++n);
if (n == 10) n = 0;
x++;
if (x == 10) break out;
}
card = (PKCard) this.table.get(point);
}
while (!card.isCardCanMove());
while (this.getPreviousCard(card) != null
&& this.getPreviousCard(card).isCardCanMove())
{
card = this.getPreviousCard(card);
}
if (a == 10) a = 0;
for (; a < 10; a++)
{
if (a != n)
{
Point p = null;
PKCard c = null;
do
{
if (p != null) a++;
p = this.getLastCardLocation(a);
int z = 0;
while (p == null)
{
p = this.getLastCardLocation(++a);
if (a == 10) a = 0;
if (a == n) a++;
z++;
if (z == 10) break out;
}
c = (PKCard) this.table.get(p);
}
while (!c.isCardCanMove());
if (c.getCardValue() == card.getCardValue() + 1)
{
card.flashCard(card);
try
{
Thread.sleep(800);
}
catch (InterruptedException e)
{
// TODO 自动生成 catch 块
e.printStackTrace();
}
c.flashCard(c);
a++;
if (a == 10) n++;
break out;
}
}
}
n++;
if (n == 10) n = 0;
x++;
if (x == 10) break out;
}
}

public void deal()
{
this.setNA();
for (int i = 0; i < 10; i++)
{
if (this.getLastCardLocation(i) == null)
{
JOptionPane.showMessageDialog(this, "有空位不能发牌!", "提示",
JOptionPane.WARNING_MESSAGE);
return;
}
}
int x = 20;
for (int i = 0; i < 10; i++)
{
Point lastPoint = this.getLastCardLocation(i);
if (c == 0)
lastPoint.y += 5;
else
lastPoint.y += 20;
table.remove(cards[c + i].getLocation());
cards[c + i].moveto(lastPoint);
table.put(new Point(lastPoint), cards[c + i]);
cards[c + i].turnFront();
cards[c + i].setCanMove(true);
this.pane.setComponentZOrder(cards[c + i], 1);
Point point = new Point(lastPoint);
if (cards[c + i].getCardValue() == 1)
{
int n = cards[c + i].whichColumnAvailable(point);
point.y -= 240;
PKCard card = (PKCard) this.table.get(point);
if (card != null && card.isCardCanMove())
{
this.haveFinish(n);
}
}
x += 101;
}
c += 10;
}

public PKCard getPreviousCard(PKCard card)
{
Point point = new Point(card.getLocation());
point.y -= 5;
card = (PKCard) table.get(point);
if (card != null) return card;
point.y -= 15;
card = (PKCard) table.get(point);
return card;
}

public PKCard getNextCard(PKCard card)
{
Point point = new Point(card.getLocation());
point.y += 5;
card = (PKCard) table.get(point);
if (card != null) return card;
point.y += 15;
card = (PKCard) table.get(point);
return card;
}

public Point getLastCardLocation(int column)
{
Point point = new Point(20 + column * 101, 25);
PKCard card = (PKCard) this.table.get(point);
if (card == null) return null;
while (card != null)
{
point = card.getLocation();
card = this.getNextCard(card);
}
return point;
}

public Point getGroundLabelLocation(int column)
{
return new Point(groundLabel[column].getLocation());
}

public void setGroundLabelZOrder()
{
for (int i = 0; i < 10; i++)
{
pane.setComponentZOrder(groundLabel[i], 105 + i);
}
}

public void haveFinish(int column)
{
Point point = this.getLastCardLocation(column);
PKCard card = (PKCard) this.table.get(point);
do
{

this.table.remove(point);
card.moveto(new Point(20 + finish * 10, 580));
pane.setComponentZOrder(card, 1);
this.table.put(card.getLocation(), card);
card.setCanMove(false);
point = this.getLastCardLocation(column);
if (point == null)
card = null;
else
card = (PKCard) this.table.get(point);
}
while (card != null && card.isCardCanMove());
finish++;
if (finish == 8)
{
JOptionPane.showMessageDialog(this, "恭喜你,过关了!", "成功",
JOptionPane.PLAIN_MESSAGE);
}
if (card != null)
{
card.turnFront();
card.setCanMove(true);
}
}
}


2、按键加载

package game;

import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.ButtonGroup;

public class AraneidMenuBar extends JMenuBar
{
/**
*
*/
private static final long serialVersionUID = 1L;
private Araneid main = null;
private JMenu jMenu = null;
private JMenu jMenu1 = null;
private JMenuItem jMenuItem = null;
private JMenuItem jMenuItem1 = null;
private JMenuItem jMenuItem2 = null;
private JRadioButtonMenuItem jRadioButtonMenuItem = null;
private JRadioButtonMenuItem jRadioButtonMenuItem1 = null;
private JRadioButtonMenuItem jRadioButtonMenuItem2 = null;
private JMenuItem jMenuItem3 = null;

private JMenuItem jMenuItem4 = null;
/**
* This is the default constructor
*/
public AraneidMenuBar(Araneid araneid)
{
super();
this.main = araneid;
initialize();
}

/**
* This method initializes this
*
* @return void
*/
private void initialize()
{
this.add(getJMenu());
this.add(getJMenu1());
}

/**
* This method initializes jMenu
*
* @return javax.swing.JMenu
*/
private JMenu getJMenu()
{
if (jMenu == null)
{
jMenu = new JMenu();
jMenu.setText("游戏");
jMenu.add(getJMenuItem1());
jMenu.add(getJMenuItem2());
jMenu.add(getJMenuItem4());
jMenu.addSeparator();
jMenu.add(getJRadioButtonMenuItem());
jMenu.add(getJRadioButtonMenuItem1());
jMenu.add(getJRadioButtonMenuItem2());
jMenu.addSeparator();
jMenu.add(getJMenuItem3());
jMenu.addMenuListener(new javax.swing.event.MenuListener() {
public void menuSelected(javax.swing.event.MenuEvent e) {
if(main.getC() < 60) getJMenuItem2().setEnabled(true);
else getJMenuItem2().setEnabled(false);
}
public void menuDeselected(javax.swing.event.MenuEvent e) {}
public void menuCanceled(javax.swing.event.MenuEvent e) {}
});
ButtonGroup group = new ButtonGroup();
group.add(getJRadioButtonMenuItem());
group.add(getJRadioButtonMenuItem1());
group.add(getJRadioButtonMenuItem2());
}
return jMenu;
}

/**
* This method initializes jMenu1
*
* @return javax.swing.JMenu
*/
private JMenu getJMenu1()
{
if (jMenu1 == null)
{
jMenu1 = new JMenu();
jMenu1.setText("帮助");
jMenu1.add(getJMenuItem());
}
return jMenu1;
}

/**
* This method initializes jMenuItem
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getJMenuItem()
{
if (jMenuItem == null)
{
jMenuItem = new JMenuItem();
jMenuItem.setText("关于");
jMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
new AboutDialog(main);
}
});
}
return jMenuItem;
}

/**
* This method initializes jMenuItem1
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getJMenuItem1()
{
if (jMenuItem1 == null)
{
jMenuItem1 = new JMenuItem();
jMenuItem1.setText("开局");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
main.newGame();
}
});
}
return jMenuItem1;
}

/**
* This method initializes jMenuItem2
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getJMenuItem2()
{
if (jMenuItem2 == null)
{
jMenuItem2 = new JMenuItem();
jMenuItem2.setText("新一轮发牌");
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
if(main.getC() < 60) main.deal();
}
});
}
return jMenuItem2;
}

/**
* This method initializes jRadioButtonMenuItem
*
* @return javax.swing.JRadioButtonMenuItem
*/
private JRadioButtonMenuItem getJRadioButtonMenuItem()
{
if (jRadioButtonMenuItem == null)
{
jRadioButtonMenuItem = new JRadioButtonMenuItem();
jRadioButtonMenuItem.setText("初级:单色");
jRadioButtonMenuItem.setSelected(true);
jRadioButtonMenuItem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
main.setGrade(Araneid.EASY);
main.initCards();
main.newGame();
}
});
}
return jRadioButtonMenuItem;
}

/**
* This method initializes jRadioButtonMenuItem1
*
* @return javax.swing.JRadioButtonMenuItem
*/
private JRadioButtonMenuItem getJRadioButtonMenuItem1()
{
if (jRadioButtonMenuItem1 == null)
{
jRadioButtonMenuItem1 = new JRadioButtonMenuItem();
jRadioButtonMenuItem1.setText("中级:双色");
jRadioButtonMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
main.setGrade(Araneid.NATURAL);
main.initCards();
main.newGame();
}
});
}
return jRadioButtonMenuItem1;
}

/**
* This method initializes jRadioButtonMenuItem2
*
* @return javax.swing.JRadioButtonMenuItem
*/
private JRadioButtonMenuItem getJRadioButtonMenuItem2()
{
if (jRadioButtonMenuItem2 == null)
{
jRadioButtonMenuItem2 = new JRadioButtonMenuItem();
jRadioButtonMenuItem2.setText("高级:四色");
jRadioButtonMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
main.setGrade(Araneid.HARD);
main.initCards();
main.newGame();
}
});
}
return jRadioButtonMenuItem2;
}

/**
* This method initializes jMenuItem3
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getJMenuItem3()
{
if (jMenuItem3 == null)
{
jMenuItem3 = new JMenuItem();
jMenuItem3.setText("退出");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
main.dispose();
System.exit(0);
}
});
}
return jMenuItem3;
}
/**
* This method initializes jMenuItem4
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getJMenuItem4() {
if (jMenuItem4 == null) {
jMenuItem4 = new JMenuItem();
jMenuItem4.setText("显示可行操作");
jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
new Show().start();
}
});
}
return jMenuItem4;
}

class Show extends Thread
{
public void run()
{
main.showEnableOperator();
}
}
}

3、游戏执行控制过程

package game;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;


public class PKCard extends JLabel implements MouseListener,
MouseMotionListener
{

/**
*
*/
private static final long serialVersionUID = 1L;
private Point point = null;
private Point initPoint = null;
private int value = 0;
private int type = 0;
private String name = null;
private Container pane = null;
private Araneid main = null;
private boolean canMove = false;
private boolean isFront = false;
private PKCard previousCard = null;

/*
* (非 Javadoc)
*
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
*/
public void mouseClicked(MouseEvent arg0)
{
// TODO 自动生成方法存根
}

public void flashCard(PKCard card)
{
new Flash(card).start();
if(main.getNextCard(card) != null)
card.flashCard(main.getNextCard(card));
}

class Flash extends Thread
{
private PKCard card = null;

public Flash(PKCard card)
{
this.card = card;
}

public void run()
{
boolean is = false;
ImageIcon icon = new ImageIcon("images/white.gif");
for (int i = 0; i < 4; i++)
{
try
{
Thread.sleep(200);
}
catch (InterruptedException e)
{
// TODO 自动生成 catch 块
e.printStackTrace();
}
if (is)
{
this.card.turnFront();
is = !is;
}
else
{
this.card.setIcon(icon);
is = !is;
}
card.updateUI();
}
}
}

/*
* (非 Javadoc)
*
* @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)
*/
public void mousePressed(MouseEvent arg0)
{
// TODO 自动生成方法存根
point = arg0.getPoint();
main.setNA();
this.previousCard = main.getPreviousCard(this);
// System.out.println(((PKCard) arg0.getSource()).initPoint);
// System.out.println(((PKCard) arg0.getSource()).getCardType());
// System.out.println();
}

/*
* (非 Javadoc)
*
* @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
*/
public void mouseReleased(MouseEvent arg0)
{
// TODO 自动生成方法存根

Point point = ((JLabel) arg0.getSource()).getLocation();
int n = this.whichColumnAvailable(point);
if (n == -1 || n == this.whichColumnAvailable(this.initPoint))
{
this.setNextCardLocation(null);
main.table.remove(this.getLocation());
this.setLocation(this.initPoint);
main.table.put(this.initPoint, this);
return;
}
point = main.getLastCardLocation(n);
boolean isEmpty = false;
PKCard card = null;
if (point == null)
{
point = main.getGroundLabelLocation(n);
isEmpty = true;
}
else
{
card = (PKCard) main.table.get(point);
}
if (isEmpty || (this.value + 1 == card.getCardValue()))
{
point.y += 40;
if (isEmpty) point.y -= 20;
this.setNextCardLocation(point);
main.table.remove(this.getLocation());
point.y -= 20;
this.setLocation(point);
main.table.put(point, this);
this.initPoint = point;
if (this.previousCard != null)
{
this.previousCard.turnFront();
this.previousCard.setCanMove(true);
}
this.setCanMove(true);
}
else
{
this.setNextCardLocation(null);
main.table.remove(this.getLocation());
this.setLocation(this.initPoint);
main.table.put(this.initPoint, this);
return;
}
point = main.getLastCardLocation(n);
card = (PKCard) main.table.get(point);
if (card.getCardValue() == 1)
{
point.y -= 240;
card = (PKCard) main.table.get(point);
if (card != null && card.isCardCanMove())
{
main.haveFinish(n);
}
}
}

public void setNextCardLocation(Point point)
{
PKCard card = main.getNextCard(this);
if (card != null)
{
if (point == null)
{
card.setNextCardLocation(null);
main.table.remove(card.getLocation());
card.setLocation(card.initPoint);
main.table.put(card.initPoint, card);
}
else
{
point = new Point(point);
point.y += 20;
card.setNextCardLocation(point);
point.y -= 20;
main.table.remove(card.getLocation());
card.setLocation(point);
main.table.put(card.getLocation(), card);
card.initPoint = card.getLocation();
}
}
}

public int whichColumnAvailable(Point point)
{
int x = point.x;
int y = point.y;
int a = (x - 20) / 101;
int b = (x - 20) % 101;
if (a != 9)
{
if (b > 30 && b <= 71)
a = -1;
else if (b > 71) a++;
}
else if (b > 71)
{
a = -1;
}
if (a != -1)
{
Point p = main.getLastCardLocation(a);
if (p == null) p = main.getGroundLabelLocation(a);
b = y - p.y;
if (b <= -96 || b >= 96) a = -1;
}
return a;
}

/*
* (非 Javadoc)
*
* @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)
*/
public void mouseEntered(MouseEvent arg0)
{
// TODO 自动生成方法存根

}

/*
* (非 Javadoc)
*
* @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
*/
public void mouseExited(MouseEvent arg0)
{
// TODO 自动生成方法存根

}

/*
* (非 Javadoc)
*
* @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent)
*/
public void mouseDragged(MouseEvent arg0)
{
// TODO 自动生成方法存根
if (canMove)
{
int x = 0;
int y = 0;
Point p = arg0.getPoint();
x = p.x - point.x;
y = p.y - point.y;
this.moving(x, y);
}
}

public void moving(int x, int y)
{
PKCard card = main.getNextCard(this);
Point p = this.getLocation();
pane.setComponentZOrder(this, 1);
main.table.remove(p);
p.x += x;
p.y += y;
this.setLocation(p);
main.table.put(p, this);
if (card != null) card.moving(x, y);
}

/*
* (非 Javadoc)
*
* @see java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent)
*/
public void mouseMoved(MouseEvent arg0)
{
// TODO 自动生成方法存根

}

/**
* This is the default constructor
*/
public PKCard(String name, Araneid araneid)
{
super();
this.type = new Integer(name.substring(0, 1)).intValue();
this.value = new Integer(name.substring(2)).intValue();
this.name = name;
this.main = araneid;
this.pane = this.main.getContentPane();
this.addMouseListener(this);
this.addMouseMotionListener(this);
this.setIcon(new ImageIcon("images/rear.gif"));
this.setSize(71, 96);
this.setVisible(true);
}

public void turnFront()
{
this.setIcon(new ImageIcon("images/" + name + ".gif"));
this.isFront = true;
}

public void turnRear()
{
this.setIcon(new ImageIcon("images/rear.gif"));
this.isFront = false;
this.canMove = false;
}

public void moveto(Point point)
{
this.setLocation(point);
this.initPoint = point;
}

public void setCanMove(boolean can)
{
this.canMove = can;
PKCard card = main.getPreviousCard(this);
if (card != null && card.isCardFront())
{
if (!can)
{
if (!card.isCardCanMove())
return;
else
card.setCanMove(can);
}
else
{
if (this.value + 1 == card.getCardValue()
&& this.type == card.getCardType())
{
card.setCanMove(can);
}
else
card.setCanMove(false);
}
}
}

public boolean isCardFront()
{
return this.isFront;
}

public boolean isCardCanMove()
{
return this.canMove;
}

public int getCardValue()
{
return value;
}

public int getCardType()
{
return type;
}
}

4、游戏基本信息

package game;

import javax.swing.JDialog;
import javax.swing.JFrame;
import java.awt.Point;

import javax.swing.JTabbedPane;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JLabel;

public class AboutDialog extends JDialog
{

private javax.swing.JPanel jContentPane = null;
protected JFrame owner = null;

private JTabbedPane jTabbedPane = null;
private JPanel jPanel = null;
private JPanel jPanel1 = null;
private JPanel jPanel2 = null;
private JPanel jPanel3 = null;
private JPanel jPanel4 = null;
private JButton jButton = null;
private JLabel jLabel = null;
private JLabel jLabel1 = null;
private JLabel jLabel2 = null;
private JLabel jLabel3 = null;
/**
* This is the default constructor
*/
public AboutDialog(JFrame frame)
{
super(frame);
owner = frame;
setResizable(false);
initialize();
}

/**
* This method initializes this
*
* @return void
*/
private void initialize()
{
this.setTitle("关于对话框");
this.setSize(209, 132);
this.setContentPane(getJContentPane());
this.setLocation();
this.setVisible(true);
this.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
owner.setEnabled(true);
AboutDialog.this.dispose();
}
});
}

/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private javax.swing.JPanel getJContentPane()
{
if (jContentPane == null)
{
jContentPane = new javax.swing.JPanel();
jContentPane.setLayout(new java.awt.BorderLayout());
jContentPane.add(getJTabbedPane(), java.awt.BorderLayout.CENTER);
jContentPane.add(getJPanel4(), java.awt.BorderLayout.SOUTH);
}
return jContentPane;
}

private void setLocation()
{
Point point = owner.getLocation();
int width = this.getWidth();
int height = this.getHeight();
int x = (int) (point.getX() + (owner.getWidth() - width) / 2);
x = (x > 1024 - width ? 1024 - width : x);
x = (x < 0 ? 0 : x);
int y = (int) (point.getY() + (owner.getHeight() - height) / 2);
y = (y > 768 - height ? 768 - height : y);
y = (y < 0 ? 0 : y);
setLocation(x, y);
}
/**
* This method initializes jTabbedPane
*
* @return javax.swing.JTabbedPane
*/
private JTabbedPane getJTabbedPane() {
if (jTabbedPane == null) {
jTabbedPane = new JTabbedPane();
jTabbedPane.addTab("关于", null, getJPanel(), null);
jTabbedPane.addTab("作者", null, getJPanel1(), null);
jTabbedPane.addTab("班级", null, getJPanel2(), null);
jTabbedPane.addTab("学号", null, getJPanel3(), null);
}
return jTabbedPane;
}
/**
* This method initializes jPanel
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel() {
if (jPanel == null) {
jLabel = new JLabel();
jPanel = new JPanel();
jLabel.setText("蜘蛛牌");
jLabel.setFont(new java.awt.Font("楷体_GB2312", java.awt.Font.BOLD, 18));
jLabel.setForeground(java.awt.Color.blue);
jPanel.add(jLabel, null);
}
return jPanel;
}
/**
* This method initializes jPanel1
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel1() {
if (jPanel1 == null) {
jLabel1 = new JLabel();
jPanel1 = new JPanel();
jLabel1.setText("XXX");
jLabel1.setFont(new java.awt.Font("楷体_GB2312", java.awt.Font.BOLD, 18));
jLabel1.setForeground(java.awt.Color.blue);
jPanel1.add(jLabel1, null);
}
return jPanel1;
}
/**
* This method initializes jPanel2
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel2() {
if (jPanel2 == null) {
jLabel2 = new JLabel();
jPanel2 = new JPanel();
jLabel2.setText("XXX计算机(XXXX)班");
jLabel2.setForeground(java.awt.Color.blue);
jLabel2.setFont(new java.awt.Font("楷体_GB2312", java.awt.Font.BOLD, 18));
jPanel2.add(jLabel2, null);
}
return jPanel2;
}
/**
* This method initializes jPanel3
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel3() {
if (jPanel3 == null) {
jLabel3 = new JLabel();
jPanel3 = new JPanel();
jLabel3.setText("020505101");
jLabel3.setForeground(java.awt.Color.blue);
jLabel3.setFont(new java.awt.Font("楷体_GB2312", java.awt.Font.BOLD, 18));
jPanel3.add(jLabel3, null);
}
return jPanel3;
}
/**
* This method initializes jPanel4
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel4() {
if (jPanel4 == null) {
jPanel4 = new JPanel();
jPanel4.add(getJButton(), null);
}
return jPanel4;
}
/**
* This method initializes jButton
*
* @return javax.swing.JButton
*/
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setText("确定");
jButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
owner.setEnabled(true);
AboutDialog.this.dispose();
}
});
}
return jButton;
}
} // @jve:decl-index=0:visual-constraint="10,10"
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值