Advertisement
Guest User

2048

a guest
Nov 28th, 2015
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.18 KB | None | 0 0
  1. package Game2048;
  2.  
  3. import java.awt.event.ActionEvent;
  4. import java.awt.event.ActionListener;
  5. import java.awt.event.KeyEvent;
  6. import java.util.ArrayList;
  7.  
  8. import javax.swing.JFrame;
  9. import javax.swing.JMenu;
  10. import javax.swing.JMenuBar;
  11. import javax.swing.JMenuItem;
  12. import javax.swing.KeyStroke;
  13. import javax.swing.WindowConstants;
  14.  
  15. public class Application {
  16.    
  17.    
  18.     static ArrayList<Scores> scorelist = new ArrayList<Scores>() ;
  19.    
  20.     private static int WIDTH = 340;
  21.     private static int HEIGHT = 430;
  22.    
  23.     public static int getWidth(){
  24.         return WIDTH;
  25.     }
  26.    
  27.     public static int getHeight(){
  28.         return HEIGHT;
  29.     }
  30.    
  31.     class MenuActionListener implements ActionListener {
  32.           public void actionPerformed(ActionEvent e) {
  33.             System.out.println("Selected:");
  34.            
  35.  
  36.             JFrame scored = new JFrame();
  37.             scored.setTitle("Scores");//Create the menu bar.
  38.            
  39.            
  40.             scored.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  41.             scored.setSize(250, 700);
  42.             scored.setResizable(false);
  43.  
  44.  
  45.             scored.setLocationRelativeTo(null);
  46.             scored.setVisible(true);
  47.  
  48.           }
  49.     }
  50.    
  51.     public static void main(String[] args) {
  52.         JFrame game = new JFrame();
  53.         game.setTitle("2048 App");//Create the menu bar.
  54.        
  55.        
  56.         // menü berakása
  57.         JMenuBar menuBar = new JMenuBar();
  58.         game.setJMenuBar(menuBar);
  59.        
  60.         JMenu menu = new JMenu("A Menu");
  61.         menu.setMnemonic(KeyEvent.VK_A);
  62.        
  63.         JMenuItem uj_jatek = new JMenuItem("Hajajaj");
  64.         uj_jatek.setVisible(true);
  65.         menu.add(uj_jatek);
  66.        
  67.        
  68.        
  69.         menuBar.add(menu);
  70.         /////////////////////////
  71.  
  72.         JMenu menusc = new JMenu("Scores");
  73.         menusc.setMnemonic(KeyEvent.VK_B);
  74.        
  75.         ////////////////////////
  76.        
  77.         JMenuItem list_scores = new JMenuItem("Mutasd a nyerteseket");
  78.         list_scores.setVisible(true);
  79.         menusc.add(list_scores);
  80.        
  81.         MenuActionListener lel = new MenuActionListener();
  82.         list_scores.addActionListener(lel);
  83.        
  84.         ////////////////////////
  85.         menuBar.add(menusc);
  86.         //////////////////////
  87.        
  88.         game.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  89.         game.setSize(WIDTH, HEIGHT);
  90.         game.setResizable(false);
  91.  
  92.         game.add(new Game2048());
  93.  
  94.         game.setLocationRelativeTo(null);
  95.         game.setVisible(true);
  96.     }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement