发布网友 发布时间:2022-04-22 20:24
共2个回答
热心网友 时间:2023-10-27 16:36
import java.awt.Color;import java.awt.GridLayout;import javax.swing.JButton;import javax.swing.JFrame; public class MiGong extends JFrame{ private static final long serialVersionUID = 1L; private static final int ROW = 8; private static final int COL = 9; int[][] map = { {2,0,1,0,0,0,1,0}, {0,0,1,0,0,0,1,0}, {0,0,1,0,1,1,0,0}, {0,1,1,1,0,0,0,0}, {0,0,0,1,0,0,0,0}, {0,1,0,0,0,1,0,1}, {0,1,1,1,1,0,0,1}, {1,1,0,0,0,1,0,1}, {1,1,0,0,0,0,0,3} }; public static void main ( String args[] ) { new MiGong (); } public MiGong () { setTitle ("迷宫"); setLayout (new GridLayout (ROW, COL, 0, 0)); for ( int h = 0; h < COL; h++ ) { for ( int g = 0; g < ROW; g++ ) { switch (map[h][g]) { case 0: JButton p = new JButton (); p.setBackground (Color.red); add (p); break; case 1: JButton q = new JButton (); q.setBackground (Color.blue); add (q); break; case 2: JButton m = new JButton ("入口"); m.setBackground (Color.green); add (m); break; case 3: JButton n = new JButton ("出口"); n.setBackground (Color.green); add (n); break; } } } pack (); setLocationRelativeTo (null); setDefaultCloseOperation (EXIT_ON_CLOSE); setVisible (true); }}热心网友 时间:2023-10-27 16:37
去游尚网,先设置机型,如果找不到机型你可以设置你手机屏幕的分辨率,调好后它会自动跳转到支持你手机的游戏