ʹÓÃÓÎϷѧϰjavaÃæÏò¶ÔÏó±à³Ì£¨2£©
ÉÏÒ»´Î£¬ÎÒÃÇÍê³ÉÁ˽çÃæµÄ×éÖ¯¡£½ÓÏÂÀ´ÎÒÃÇÍê³ÉÒµÎñÂß¼¡£
1£©ÈçºÎÍê³ÉÖÜΧÏàÁڵİ´Å¥±äÉ«¡£
·ÖÎö£ºÒòΪÎÒÃÇ×öÁËÒ»¸ö5*5µÄÊý×é¡£²¢ÇÒÊÂÏÈÎÒÃǸøÿ¸ö×Ô¶¨ÒåµÄbutton¼ÓÁËxºÍy×ø±ê
¾ÍÊÇΪÁ˸ü·½±ãµÄ¸øÏàÁڵİ´Å¥±äÉ«¡£
µ±ÎÒÃǵã»÷(2£¬2)°´Å¥Ê±£¬ÖÜΧµÄ 4¸ö°´Å¥»á±ä»¯¡£
µ±È»Ê×ÏÈÎÒÃÇÓ¦¸ÃÏȸøÿ¸ö°´Å¥Ôö¼Ó¼àÌýÆ÷¡£ÎÒÃÇʹÓÃÄÚ²¿ÀàÀ´Íê³É´Ë¹¦ÄÜ
ÄÚ²¿ÀàÈçÏÂ
//¶¨ÒåÒ»¸öÄÚ²¿À࣬רÓÃÓÚ´¦Àíbuttonʼþ
class buttonHandler implements ActionListener {
MyButton btn;
//¹¹Ôì·½·¨£¬µÃµ½ÐèÒª´¦ÀíµÄbutton
public buttonHandler(MyButton button) {
btn = button;
}
public void actionPerformed(ActionEvent e) {
changeRound(btn);
if (isWin()) {//Èç¹ûÓ®ÁË£¬ÏÔʾһ¸ö¶Ô»°¿ò
disableAll(); //²»ÄÜÔÙµã»÷ÁË¡£
JOptionPane.showMessageDialog(null, "¹§Ï²¹§Ï²£¡Äú¹ý¹ØÁË");
}
}
}
ÔÙ´ÎÇ¿µ÷Õâ¸öÀàÊǶ¨ÒåÔÚGameÀàÖеġ£
½ÓÏÂÁËÒª»Øµ½ÎÒÃǵÄÄ¿µÄ--ÏàÁÚ°´Å¥£¬±äÉ«²ßÂÔÈçÏÂ
//¸Ä±ä×Ô¼ºÒÔ¼°ËÄÖܵİ´Å¥µÄÑÕÉ«
public void changeRound(MyButton btn) {
int i = btn.getXCord();//È¡µÃ°´Å¥ËùÔÚµÄλÖÃ
int j = btn.getYCord();
buttons[i][j].changeColor(); //ÏÈ×Ô¼º±äÉ«£¬Ò²¿ÉÒÔbtn.changeColor();
if (j > 0) {
buttons[i][j - 1].changeColor();//ÉÏ
}
if (j < N - 1) {
buttons[i][j + 1].changeColor();//ÏÂ
}
if (i > 0) {
buttons[i - 1][j].changeColor();//×ó
}
if (i < N - 1) {
buttons[i + 1][j].changeColor();//ÓÒ
}
}
×îºó£¬Ã¿´Îµã»÷°´Å¥¶¼Òª¼ì²â°´Å¥ÊÇ·ñÈ«²¿ÒѾ±»¸ã¶¨ÁË¡£
//¼ì²âÍæ¼ÒÊÇ·ñÒѾӮÁ˵ķ½·¨
//˼·£º½«ËùÓеİ´Å¥µÄ±³¾°É«¶¼²éÒ»±é
public boolean isWin() {
boolean flag = true;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (buttons[i][j].getBackground() == Color.white) {
return false;
}
}
}
return flag;
}
ok. ³ÌÐò¾ÍÒѾ»ù±¾¸ã¶¨ÁË¡£
×ܽáÒ»ÏÂ֪ʶµã£º
1£©¼Ì³Ð
2£©Êý×é
3£©java swingʼþ
4£©ÄÚ²¿Àà
ÆäÖÐswing ºÍÄÚ²¿À໹ÓÐһЩϸ½Ú¿ÉÒÔÉîÈë¡£´ó¼Ò¿ÉÒÔ×Ô¼ºÈ¥²éÏà¹ØµÄ×ÊÁÏ
´úÂëÏÂÔØ
http://cnjava.blog.51cto.com
Ïà¹ØÎĵµ£º
ÏÈÀ´Á˽âÒ»ÏÂÁ´±íģʽµÄÔÀí£º
Ê×ÏÈдһ¸öJavaBean£¬ÄÚÈÝÊÇÒªÌí¼ÓµÄÔªËغ͸ÃÔªËصĽڵ㡣
public class NodeBean implements Serializable
{
private Object data; //ÔªËر¾Éí
private NodeBean next; //ÏÂÒ»¸ö½Úµã
&n ......
¶¯Ì¬¹¹½¨Ê÷µÄÄ£Ðͺͷ½·¨£º
/**
* ¸ÃÄ£¿éÖ÷ÒªÊǽ«ÎÞ¹æÔò´æ·ÅµÄ¶ÔÏó½øÐÐÒ»¸öÓÐ×éÖ¯µÄÊ÷Ðνڵ㴦Àí
* @author ÏļҼª<jijin0223@126.com>
*
*/
public class SystemMenuTreeModel {
public SystemMenuTreeModel(){
& ......
Èç¹ûÄãjavaÒѾÈëÃÅÁË£¬½¨ÒéÄãÏȲ»È¥Ïë´úÂë¡£¶øÊÇÈ¥ÏëÍê³ÉÈÎÎñÒª×öµÄ²½Öè¡£ÏëºÃÁ˺óÄÄÅÂÄãÈ¥Õ³Ìù´úÂ붼¿ÉÒÔ¡£±à³ÌÊÇ¿¼ÑéµÄ˼ά£¬²»ÊÇд´úÂëµÄËٶȣ¬ºÍ¶Ô´úÂëµÄ¼ÇÒäÐÔ¡£
±à³ÌÊÇÒ»¼þ¾Ñé»î, ²»ÊÇ¿´ÊéÄܽâ¾öµÄ, ±à³ÌÖÐÓöµ½µÄÎÊÌâǧÆæ°Ù¹Ö, ¸ù±¾²»ÊÇÒ»±¾Êé»òÕßn±¾ÄܸøÄã½â¾öµÄ£¬±ØÐë×Ô¼ºÇ××ÔÈ¥Ìå»á
ËùÒÔ, ÕÒ±¾ÓÐʵÀýµ ......
JavaʹµÃ¸´ÔÓÓ¦ÓõĿª·¢±äµÃÏà¶Ô¼òµ¥£¬ºÁÎÞÒÉÎÊ£¬ËüµÄÕâÖÖÒ×ÓÃÐÔ¶ÔJavaµÄ´ó·¶Î§Á÷Ðй¦²»¿Éû¡£È»¶ø£¬ÕâÖÖÒ×ÓÃÐÔʵ¼ÊÉÏÊÇÒ»°ÑË«Èн£¡£Ò»¸öÉè¼ÆÁ¼ºÃµÄJava³ÌÐò£¬ÐÔÄܱíÏÖÍùÍù²»ÈçÒ»¸öͬÑùÉè¼ÆÁ¼ºÃµÄC++³ÌÐò¡£ÔÚJava³ÌÐòÖУ¬ÐÔÄÜÎÊÌâµÄ´ó²¿·ÖÔÒò²¢²»ÔÚÓÚJavaÓïÑÔ£¬¶øÊÇÔÚÓÚ³ÌÐò±¾Éí¡£Ñø³ÉºÃµÄ´úÂë±àдϰ¹ß·Ç³£ÖØÒª£¬±ÈÈçÕýÈ·µ ......
http://www.javaworld.com/javaworld/javaqa/2000-05/03-qa-0526-pass.html
Does Java pass by reference or pass by value?
Why can't you swap in Java?
By Tony
Sintes, JavaWorld.com, 05/26/00
Print
Email
Feedback
Resources
Discuss
(76)
Digg
Reddit
SlashDot
Stumble
......