LaCaraDeLaVerga

MultiTab

Sep 12th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 8.66 KB | None | 0 0
  1. package presentacion;
  2.  
  3. import java.awt.EventQueue;
  4. import java.net.URL;
  5. import javax.swing.JFrame;
  6. import javax.swing.JButton;
  7. import javax.swing.JLabel;
  8. import javax.swing.JTextField;
  9. import java.awt.Color;
  10. import javax.swing.JMenu;
  11. import javax.swing.JCheckBoxMenuItem;
  12. //import javax.print.DocFlavor.URL;
  13. import javax.sound.sampled.AudioInputStream;
  14. import javax.sound.sampled.AudioSystem;
  15. import javax.sound.sampled.Clip;
  16. import javax.sound.sampled.LineUnavailableException;
  17. import javax.sound.sampled.UnsupportedAudioFileException;
  18. import javax.swing.AbstractAction;
  19. import java.awt.event.ActionEvent;
  20. import javax.swing.Action;
  21. import java.awt.SystemColor;
  22. import java.awt.Font;
  23. import javax.swing.JPanel;
  24. import javax.swing.border.SoftBevelBorder;
  25. import javax.swing.border.BevelBorder;
  26. import javax.swing.JProgressBar;
  27. import javax.swing.UIManager;
  28. import javax.swing.JEditorPane;
  29. import java.awt.event.ActionListener;
  30. import java.awt.event.MouseAdapter;
  31. import java.awt.event.MouseEvent;
  32. import java.io.BufferedReader;
  33. import java.io.FileNotFoundException;
  34. import java.io.FileReader;
  35. import java.io.IOException;
  36. import java.io.InputStream;
  37. import java.awt.CardLayout;
  38. import javax.swing.JSpinner;
  39. import javax.swing.SpinnerNumberModel;
  40. import javax.swing.JToggleButton;
  41. import javax.swing.JCheckBox;
  42. import javax.swing.JList;
  43. import javax.swing.JSlider;
  44. import javax.swing.JTextPane;
  45.  
  46.  
  47. public class multiTab {
  48.  
  49.     private JFrame frame;
  50.     public String highScore="";
  51.     public int  puntaje = 0;
  52.    
  53.     /**
  54.      * Launch the application.
  55.      */
  56.     public static void main(String[] args) {
  57.         EventQueue.invokeLater(new Runnable() {
  58.             public void run() {
  59.                 try {
  60.                     multiTab window = new multiTab();
  61.                     musicaFondo(window);
  62.                     window.frame.setVisible(true);
  63. //                  musicaFondo(window);
  64.                 } catch (Exception e) {
  65.                     e.printStackTrace();
  66.                 }
  67.             }
  68.         });
  69.     }
  70.  
  71.     /**
  72.      * Create the application.
  73.      */
  74.     public multiTab() {
  75.         initialize();
  76.     }
  77.  
  78.     /**
  79.      * Initialize the contents of the frame.
  80.      */
  81.     private void initialize() {
  82.  
  83. //      VARIABLES
  84.         int alto = 600 ;
  85.         int ancho =600 ;
  86.        
  87.        
  88.         frame = new JFrame();
  89.         frame.getContentPane().setForeground(new Color(0, 0, 0));
  90.         frame.getContentPane().setFont(new Font("Arial Narrow", Font.BOLD, 14));
  91.         frame.setBackground(SystemColor.inactiveCaption);
  92.         frame.getContentPane().setBackground(new Color(222, 184, 135));
  93.         frame.getContentPane().setLayout(new CardLayout(0, 0));
  94.         frame.setSize(alto, ancho);
  95.         frame.setResizable(false);
  96.         frame.setTitle("2048-UNGS");
  97.        
  98.     //JPANELS++
  99.         final JPanel panelMenu = new JPanel();
  100.         panelMenu.setBackground(new Color(100, 149, 237));
  101.         frame.getContentPane().add(panelMenu, "name_20725192591211");
  102.         panelMenu.setLayout(null);
  103.        
  104.         final JPanel panelGame = new JPanel();
  105.         frame.getContentPane().add(panelGame, "name_20728442959615");
  106.        
  107.         final JPanel panelOpc = new JPanel();
  108.        
  109.         panelOpc.setBackground(new Color(100, 149, 237));
  110.         frame.getContentPane().add(panelOpc, "name_20731659673905");
  111.         panelOpc.setLayout(null);
  112.        
  113.        
  114.        
  115.        
  116.        
  117.         //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  118.        
  119.     //ELEMENTOS DEL PANEL MENU **
  120.        
  121.         JButton button = new JButton("2048");
  122.         button.setForeground(new Color(0, 0, 0));
  123.         button.setFont(new Font("Tahoma", Font.PLAIN, 50));
  124.         button.setBackground(new Color(100, 149, 237));
  125.         button.setBounds(200, 75, 200, 100);
  126.         panelMenu.add(button);
  127.        
  128.         JButton btnJuegoNuevo = new JButton("modo cl\u00E1sico");
  129.         btnJuegoNuevo.addActionListener(new ActionListener() {
  130.             public void actionPerformed(ActionEvent arg0) {
  131.  
  132.  
  133.             }
  134.         });
  135.         btnJuegoNuevo.setForeground(new Color(0, 0, 0));
  136.         btnJuegoNuevo.setFont(new Font("Tahoma", Font.PLAIN, 25));
  137.         btnJuegoNuevo.setBackground(new Color(100, 149, 237));
  138.         btnJuegoNuevo.setBounds(200, 200, 200, 100);
  139.         panelMenu.add(btnJuegoNuevo);
  140.        
  141.         JButton btnOpciones = new JButton("Desafio ");
  142.         btnOpciones.addActionListener(new ActionListener() {
  143.             public void actionPerformed(ActionEvent e) {
  144.             panelMenu.setVisible(false);
  145.             panelOpc.setVisible(true);
  146.            
  147.             }
  148.         });
  149.         btnOpciones.setForeground(new Color(0, 0, 0));
  150.         btnOpciones.setFont(new Font("Tahoma", Font.PLAIN, 40));
  151.         btnOpciones.setBackground(new Color(100, 149, 237));
  152.         btnOpciones.setBounds(200, 315, 200, 100);
  153.         panelMenu.add(btnOpciones);
  154.        
  155.         JLabel lblUniversidadNacionalGeneral = new JLabel("Universidad Nacional General Sarmiento ");
  156.         lblUniversidadNacionalGeneral.setBounds(180, 472, 295, 34);
  157.         panelMenu.add(lblUniversidadNacionalGeneral);
  158.        
  159.         JLabel lblTrabajoPracticoN = new JLabel("Programaci\u00F3n III - Trabajo Pr\u00E1ctico n\u00B01");
  160.         lblTrabajoPracticoN.setBounds(185, 511, 228, 14);
  161.         panelMenu.add(lblTrabajoPracticoN);
  162.        
  163.         JLabel lblJorgeRearteCarvalho = new JLabel("Jorge Rearte Carvalho - Jeremias Medrano");
  164.         lblJorgeRearteCarvalho.setBounds(176, 537, 301, 14);
  165.         panelMenu.add(lblJorgeRearteCarvalho);
  166.        
  167.         JCheckBox chckbxSonidos = new JCheckBox("MUTE");
  168.         chckbxSonidos.setBackground(new Color(100, 149, 237));
  169.         chckbxSonidos.setBounds(6, 7, 97, 23);
  170.         panelMenu.add(chckbxSonidos);
  171.        
  172.         JLabel lblPuntajeMsAlto = new JLabel("Puntaje m\u00E1s alto :");
  173.         lblPuntajeMsAlto.setBounds(462, 11, 122, 34);
  174.         panelMenu.add(lblPuntajeMsAlto);
  175.        
  176.         JTextPane textPane = new JTextPane();
  177.         textPane.setBounds(449, 53, 135, 65);
  178.         panelMenu.add(textPane);
  179.        
  180.        
  181. //      ******************************************************************
  182.        
  183.        
  184.         //ELEMENTOS DE OPCIONES
  185.         JButton btnNewButton = new JButton("Tama\u00F1o del Tablero");
  186.         btnNewButton.setFont(new Font("Tahoma", Font.PLAIN, 35));
  187.         btnNewButton.setBackground(new Color(100, 149, 237));
  188.         btnNewButton.setBounds(100, 27, 400, 110);
  189.         panelOpc.add(btnNewButton);
  190.        
  191.         JButton btnx = new JButton("3X3");
  192.         btnx.setBackground(new Color(100, 149, 237));
  193.         btnx.setFont(new Font("Tahoma", Font.PLAIN, 25));
  194.         btnx.setBounds(110, 148, 100, 50);
  195.         panelOpc.add(btnx);
  196.        
  197.         JButton btnx_1 = new JButton("4X4");
  198.         btnx_1.setBackground(new Color(100, 149, 237));
  199.         btnx_1.setFont(new Font("Tahoma", Font.PLAIN, 25));
  200.         btnx_1.setBounds(250, 148, 100, 50);
  201.         panelOpc.add(btnx_1);
  202.        
  203.         JButton btnx_2 = new JButton("5X5");
  204.         btnx_2.setFont(new Font("Tahoma", Font.PLAIN, 25));
  205.         btnx_2.setBackground(new Color(100, 149, 237));
  206.         btnx_2.setBounds(382, 148, 100, 50);
  207.         panelOpc.add(btnx_2);
  208.        
  209.         JButton btnx_3 = new JButton("6X6");
  210.         btnx_3.setFont(new Font("Tahoma", Font.PLAIN, 25));
  211.         btnx_3.setBackground(new Color(100, 149, 237));
  212.         btnx_3.setBounds(110, 240, 100, 50);
  213.         panelOpc.add(btnx_3);
  214.        
  215.         JButton btnx_4 = new JButton("7X7");
  216.         btnx_4.setFont(new Font("Tahoma", Font.PLAIN, 25));
  217.         btnx_4.setBackground(new Color(100, 149, 237));
  218.         btnx_4.setBounds(250, 240, 100, 50);
  219.         panelOpc.add(btnx_4);
  220.        
  221.         JButton btnx_5 = new JButton("8X8");
  222.         btnx_5.setFont(new Font("Tahoma", Font.PLAIN, 25));
  223.         btnx_5.setBackground(new Color(100, 149, 237));
  224.         btnx_5.addActionListener(new ActionListener() {
  225.             public void actionPerformed(ActionEvent arg0) {
  226.             }
  227.         });
  228.         btnx_5.setBounds(382, 240, 100, 50);
  229.         panelOpc.add(btnx_5);
  230.        
  231.         JButton btnx_6 = new JButton("9X9");
  232.         btnx_6.setBackground(new Color(100, 149, 237));
  233.         btnx_6.setFont(new Font("Tahoma", Font.PLAIN, 25));
  234.         btnx_6.setBounds(170, 320, 100, 50);
  235.         panelOpc.add(btnx_6);
  236.        
  237.         JButton btnx_7 = new JButton("10X10");
  238.         btnx_7.setFont(new Font("Tahoma", Font.PLAIN, 20));
  239.         btnx_7.setBackground(new Color(100, 149, 237));
  240.         btnx_7.setBounds(329, 322, 100, 50);
  241.         panelOpc.add(btnx_7);
  242.        
  243.         JLabel lblTeDesafiamosA = new JLabel("Te desafiamos a que ganes en los distintos tableros , si lo haces seras redirigido a un video porno espectacular");
  244.         lblTeDesafiamosA.setBounds(20, 383, 564, 67);
  245.         panelOpc.add(lblTeDesafiamosA);
  246.        
  247.  
  248.     }
  249.    
  250.    
  251.     public static void musicaFondo(Object multiTab) throws UnsupportedAudioFileException, IOException, LineUnavailableException
  252.     {
  253.         URL url = multiTab.getClass().getResource("sonidos/fondo.wav");
  254.         AudioInputStream sound = AudioSystem.getAudioInputStream(url);
  255.         Clip clip = AudioSystem.getClip();
  256.         clip.open(sound);
  257.         clip.start();
  258.         clip.loop(Clip.LOOP_CONTINUOUSLY);
  259.     }
  260.  
  261.     private String Highscore () throws FileNotFoundException{
  262.         String ret = "";
  263.         FileReader readFile = null ;
  264.         BufferedReader reader =null;
  265.         //formato =  Jorge: 666
  266.         try {
  267.  
  268.             readFile = new FileReader ("ranking.dat");
  269.               reader = new BufferedReader (readFile);
  270.             return reader.readLine();
  271.         } catch (Exception e) {
  272.             ret = "0" ;
  273.         }
  274.         finally{
  275.             try {
  276.                 reader.close();
  277.             } catch (Exception e2) {
  278.                 e2.printStackTrace();
  279.             }
  280.         }
  281.         return ret ;
  282.     }
  283. }
Add Comment
Please, Sign In to add comment