亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

2048的一段代碼,求解答?

2048的一段代碼,求解答?

cyc川 2017-03-07 15:48:28
?static JLabel jLabel2 = new JLabel((Icon) new ImageIcon("2.png"));?static JLabel jLabel4 = new JLabel((Icon) new ImageIcon("4.png"));?static JLabel jLabel8 = new JLabel((Icon) new ImageIcon("8.png"));?static JLabel jLabel16 = new JLabel((Icon) new ImageIcon("16.png"));?static JLabel jLabel32 = new JLabel((Icon) new ImageIcon("32.png"));?static JLabel jLabel64 = new JLabel((Icon) new ImageIcon("64.png"));?static JLabel jLabel128 = new JLabel((Icon) new ImageIcon("128.png"));?static JLabel jLabel256 = new JLabel((Icon) new ImageIcon("256.png"));?static JLabel jLabel512 = new JLabel((Icon) new ImageIcon("512.png"));?static JLabel jLabel1024 = new JLabel((Icon) new ImageIcon("1024.png"));?static JLabel jLabel2048 = new JLabel((Icon) new ImageIcon("2048.png"));?static JLabel jLabel1 = new JLabel((Icon) new ImageIcon("1.png"));?static JLabel jLabel0 = new JLabel((Icon) new ImageIcon("bj.png"));?static JLabel im = null;?private Panel panel1 = new Panel();?public static JLabel Image(int i) {??if (i == 2) {???????im = jLabel2;??} else if (i == 4) {???????im = jLabel4;??} else if (i == 8) {???????im = jLabel8;??} else if (i == 16) {???????im = jLabel16;??} else if (i == 32) {???????im = jLabel32;??} else if (i == 64) {???????im = jLabel64;??} else if (i == 128) {???????im = jLabel128;??} else if (i == 256) {???????im = jLabel256;??} else if (i == 512) {???????im = jLabel512;??} else if (i == 1024) {???im = jLabel1024;??} else if (i == 2048) {???????im = jLabel2048;??} else if (i == -1) {???????// System.out.println("出現數字1");???????im = jLabel1;??} else if (i == 0) {???????im = jLabel0;??}??????return im;?}?public text(int[][] array) {??panel1.setLayout(new GridLayout(4, 4));??JLabel image = null;??for (int i = 0; i < 4; i++) {???????for (int j = 0; j < 4; j++) {????????????image = Image(array[i][j]);????????????add(image);//此處應該是問題所在//panel1.add(new Label(String.valueOf(array[i][j])));???????????????????}??}??setLayout(new GridBagLayout());??GridBagConstraints c = new GridBagConstraints();??c.gridx = c.gridy = 0;??add(panel1, c);?}//在main中調用text(int[][] array);text(int[][] array)中調用?Image(int i);根據傳入不同的數字,分別輸出對應的圖片。如果用panel1.add(new Label(String.valueOf(array[i][j])));該語句的話,可以在界面中輸出數字,可是用image = Image(array[i][j]);?? ?add(image);?? 。界面里什么都沒有,求解答。。。。。謝謝
查看完整描述

目前暫無任何回答

  • 0 回答
  • 0 關注
  • 1100 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號