資源簡介
以前的Java課作業,做的比較完整,運行良好,下載學習

代碼片段和文件信息
package?black_white;
import?java.awt.*;
import?java.awt.event.*;
import?javax.swing.*;
import?haha_game.RecButton;
public?class?main?extends?Jframe?implements?ActionListenerMouseListener{
private?static?int?n=10stop_times=0over_style=0;
private?int?x=0y=0num1=2num2=2; //記錄雷的總數目
private?JTextField?player1_txtplayer2_txt;
private?JPanel?main_panel=new?JPanel();
private?JLabel[][]?label;
private?int[][]?mark;
private?int[][]?cost1;
private?int[][]?cost2;
private?JLabel?player1_labelplayer2_label;
private?RecButton?reset_button;
private?int?ijwide=0height=0turn=1;
private?boolean?complete=truefailed=false;
Icon?image;
public?main()
{
label=new?JLabel[n][n];
cost1=new?int[n][n];
cost2=new?int[n][n];
mark=new?int[n][n];
settitle(“HAHA極品黑白棋“);
wide=n*30+45;
height=n*30+125;
setSize(wideheight);
setLocationRelativeTo(null);?
Container?c=getContentPane();
c.setLayout(null);
c.setBackground(Color.black);
main_panel.setLayout(null);
main_panel.setBackground(Color.LIGHT_GRAY);
for(i=0;i {
for(j=0;j {
label[i][j]=new?JLabel();
label[i][j].addMouseListener(this);
label[i][j].setBounds(new?Rectangle(1+30*j?1+30*(i)3030));
main_panel.add(label[i][j]);
}
}
map_ini();
player1_label=new?JLabel(“玩家:“);
player2_label=new?JLabel(“電腦:“);
player1_label.setFont(new?Font(“宋體“Font.BOLD15));
player2_label.setFont(new?Font(“宋體“Font.BOLD15));
player1_label.setForeground(Color.red);
player2_label.setForeground(Color.red);
//Download?by?http://www.codefans.net
player1_txt=new?JTextField(10);
player2_txt=new?JTextField(10);
player1_txt.setText(““+num1);player1_txt.setBackground(Color.DARK_GRAY);
player2_txt.setText(““+num2);player2_txt.setBackground(Color.DARK_GRAY);
player1_txt.setEnabled(false);
player2_txt.setEnabled(false);
reset_button=new?RecButton(“RESET“);
reset_button.setForeground(Color.green);
reset_button.addActionListener(this);
main_panel.setBounds(new?Rectangle(104030*n30*n));
player1_label.setBounds(new?Rectangle(5104520));
player1_txt.setBounds(new?Rectangle(50103020));
player2_label.setBounds(new?Rectangle(100104520));
player2_txt.setBounds(new?Rectangle(145103020));
reset_button.setBounds(new?Rectangle(190108020));
c.add(main_panel);
c.add(player1_label);
c.add(player1_txt);
c.add(player2_label);
c.add(player2_txt);
c.add(reset_button);
}
public?void?actionPerformed(ActionEvent?e)
{
if(e.getActionCommand().equals(“RESET“))
{
map_ini();
complete=false;
failed=false;
num1=2;player1_txt.setText(num1+““);
num2=2;player2_txt.setText(num2+““);
//cvc();
}
}
private?boolean?complete()
{
boolean?over1=trueover2=trueover3=true;
for(i=0;i {
for(j=0;j {
if(mark[i][j]==0)
{
over1=false;
}
else?if(mark[i][j]==1)
{
over2=false;
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
-----------?---------??----------?-----??----
??????????????5337358????????????????????618
評論
共有 條評論