package _2048;
import java.awt.Color;
import java.net.URL;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
/**
 * 2048游戏主界面
 * @author zzc
 *
 */
public class GamePlay extends JFrame {
	URL url11 = GamePlay.class.getResource("上1.png");
	URL url12 = GamePlay.class.getResource("上2.png");
	URL url13 = GamePlay.class.getResource("上3.png");
	
	URL url21 = GamePlay.class.getResource("下1.png");
	URL url22 = GamePlay.class.getResource("下2.png");
	URL url23 = GamePlay.class.getResource("下3.png");
	
	URL url31 = GamePlay.class.getResource("左1.png");
	URL url32 = GamePlay.class.getResource("左2.png");
	URL url33 = GamePlay.class.getResource("左3.png");
	
	URL url41 = GamePlay.class.getResource("右1.png");
	URL url42 = GamePlay.class.getResource("右2.png");
	URL url43 = GamePlay.class.getResource("右3.png");
	
	public static void main(String[] args) {
		GamePlay play=new GamePlay();
		play.Init();
	}
	
	public void Init(){
		this.setSize(590, 500);
		this.setLocation(300, 160);
		this.setTitle("2048");
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		MyPanel mypanel=new MyPanel();
		mypanel.setLayout(null);
		mypanel.setBackground(Color.white);
		this.add(mypanel);
		
		//方向按钮
		JButton bt1=new JButton();
		bt1.setBounds(480,290, 35, 35);
		bt1.setBackground(Color.white);
		bt1.setIcon(new ImageIcon(url11));
		bt1.setRolloverIcon(new ImageIcon(url12));
		bt1.setPressedIcon(new ImageIcon(url13));
		bt1.setBorderPainted(false);
		bt1.setActionCommand("up");
		bt1.addActionListener(mypanel);
		mypanel.add(bt1);
		
		JButton bt2=new JButton();
		bt2.setBounds(480,390, 35, 35);
		bt2.setBackground(Color.white);
		bt2.setIcon(new ImageIcon(url21));
		bt2.setRolloverIcon(new ImageIcon(url22));
		bt2.setPressedIcon(new ImageIcon(url23));
		bt2.setBorderPainted(false);
		bt2.setActionCommand("down");
		bt2.addActionListener(mypanel);
		mypanel.add(bt2);
		
		JButton bt3=new JButton();
		bt3.setBounds(435,340, 35, 35);
		bt3.setBackground(Color.white);
		bt3.setIcon(new ImageIcon(url31));
		bt3.setRolloverIcon(new ImageIcon(url32));
		bt3.setPressedIcon(new ImageIcon(url33));
		bt3.setBorderPainted(false);
		bt3.setActionCommand("left");
		bt3.addActionListener(mypanel);
		mypanel.add(bt3);
		
		JButton bt4=new JButton();
		bt4.setBounds(525,340, 35, 35);
		bt4.setBackground(Color.white);
		bt4.setIcon(new ImageIcon(url41));
		bt4.setRolloverIcon(new ImageIcon(url42));
		bt4.setPressedIcon(new ImageIcon(url43));
		bt4.setBorderPainted(false);
		bt4.setActionCommand("right");
		bt4.addActionListener(mypanel);
		mypanel.add(bt4);
		
		
		this.setVisible(true);
	}
	
}
 最近下载更多
最近下载更多
                 最近浏览更多
最近浏览更多
                
                2354593759    
                2024年12月31日
            
            
                    暂无贡献等级
            
        
                qqqww11     LV2
                2024年6月26日
            
            
        
                鬼屋报道     LV3
                2024年6月1日
            
            
        
                7456321     LV1
                2024年4月22日
            
            
        
                ClydeSon     LV5
                2023年12月27日
            
            
        
                微信网友_6793785677565952     LV1
                2023年12月25日
            
            
        
                lshlsh    
                2023年12月25日
            
            
                    暂无贡献等级
            
        
                bangyiyang     LV2
                2023年12月21日
            
            
        
                1112WHQ     LV7
                2023年11月3日
            
            
        
                jiangneng666     LV2
                2023年10月20日
            
            
        
 
                 
                 
                