Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package presentacion;
- import java.awt.EventQueue;
- import java.net.URL;
- import javax.swing.JFrame;
- import javax.swing.JButton;
- import javax.swing.JLabel;
- import javax.swing.JTextField;
- import java.awt.Color;
- import javax.swing.JMenu;
- import javax.swing.JCheckBoxMenuItem;
- //import javax.print.DocFlavor.URL;
- import javax.sound.sampled.AudioInputStream;
- import javax.sound.sampled.AudioSystem;
- import javax.sound.sampled.Clip;
- import javax.sound.sampled.LineUnavailableException;
- import javax.sound.sampled.UnsupportedAudioFileException;
- import javax.swing.AbstractAction;
- import java.awt.event.ActionEvent;
- import javax.swing.Action;
- import java.awt.SystemColor;
- import java.awt.Font;
- import javax.swing.JPanel;
- import javax.swing.border.SoftBevelBorder;
- import javax.swing.border.BevelBorder;
- import javax.swing.JProgressBar;
- import javax.swing.UIManager;
- import javax.swing.JEditorPane;
- import java.awt.event.ActionListener;
- import java.awt.event.MouseAdapter;
- import java.awt.event.MouseEvent;
- import java.io.BufferedReader;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- import java.io.InputStream;
- import java.awt.CardLayout;
- import javax.swing.JSpinner;
- import javax.swing.SpinnerNumberModel;
- import javax.swing.JToggleButton;
- import javax.swing.JCheckBox;
- import javax.swing.JList;
- import javax.swing.JSlider;
- import javax.swing.JTextPane;
- public class multiTab {
- private JFrame frame;
- public String highScore="";
- public int puntaje = 0;
- /**
- * Launch the application.
- */
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- multiTab window = new multiTab();
- musicaFondo(window);
- window.frame.setVisible(true);
- // musicaFondo(window);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * Create the application.
- */
- public multiTab() {
- initialize();
- }
- /**
- * Initialize the contents of the frame.
- */
- private void initialize() {
- // VARIABLES
- int alto = 600 ;
- int ancho =600 ;
- frame = new JFrame();
- frame.getContentPane().setForeground(new Color(0, 0, 0));
- frame.getContentPane().setFont(new Font("Arial Narrow", Font.BOLD, 14));
- frame.setBackground(SystemColor.inactiveCaption);
- frame.getContentPane().setBackground(new Color(222, 184, 135));
- frame.getContentPane().setLayout(new CardLayout(0, 0));
- frame.setSize(alto, ancho);
- frame.setResizable(false);
- frame.setTitle("2048-UNGS");
- //JPANELS++
- final JPanel panelMenu = new JPanel();
- panelMenu.setBackground(new Color(100, 149, 237));
- frame.getContentPane().add(panelMenu, "name_20725192591211");
- panelMenu.setLayout(null);
- final JPanel panelGame = new JPanel();
- frame.getContentPane().add(panelGame, "name_20728442959615");
- final JPanel panelOpc = new JPanel();
- panelOpc.setBackground(new Color(100, 149, 237));
- frame.getContentPane().add(panelOpc, "name_20731659673905");
- panelOpc.setLayout(null);
- //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- //ELEMENTOS DEL PANEL MENU **
- JButton button = new JButton("2048");
- button.setForeground(new Color(0, 0, 0));
- button.setFont(new Font("Tahoma", Font.PLAIN, 50));
- button.setBackground(new Color(100, 149, 237));
- button.setBounds(200, 75, 200, 100);
- panelMenu.add(button);
- JButton btnJuegoNuevo = new JButton("modo cl\u00E1sico");
- btnJuegoNuevo.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- }
- });
- btnJuegoNuevo.setForeground(new Color(0, 0, 0));
- btnJuegoNuevo.setFont(new Font("Tahoma", Font.PLAIN, 25));
- btnJuegoNuevo.setBackground(new Color(100, 149, 237));
- btnJuegoNuevo.setBounds(200, 200, 200, 100);
- panelMenu.add(btnJuegoNuevo);
- JButton btnOpciones = new JButton("Desafio ");
- btnOpciones.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- panelMenu.setVisible(false);
- panelOpc.setVisible(true);
- }
- });
- btnOpciones.setForeground(new Color(0, 0, 0));
- btnOpciones.setFont(new Font("Tahoma", Font.PLAIN, 40));
- btnOpciones.setBackground(new Color(100, 149, 237));
- btnOpciones.setBounds(200, 315, 200, 100);
- panelMenu.add(btnOpciones);
- JLabel lblUniversidadNacionalGeneral = new JLabel("Universidad Nacional General Sarmiento ");
- lblUniversidadNacionalGeneral.setBounds(180, 472, 295, 34);
- panelMenu.add(lblUniversidadNacionalGeneral);
- JLabel lblTrabajoPracticoN = new JLabel("Programaci\u00F3n III - Trabajo Pr\u00E1ctico n\u00B01");
- lblTrabajoPracticoN.setBounds(185, 511, 228, 14);
- panelMenu.add(lblTrabajoPracticoN);
- JLabel lblJorgeRearteCarvalho = new JLabel("Jorge Rearte Carvalho - Jeremias Medrano");
- lblJorgeRearteCarvalho.setBounds(176, 537, 301, 14);
- panelMenu.add(lblJorgeRearteCarvalho);
- JCheckBox chckbxSonidos = new JCheckBox("MUTE");
- chckbxSonidos.setBackground(new Color(100, 149, 237));
- chckbxSonidos.setBounds(6, 7, 97, 23);
- panelMenu.add(chckbxSonidos);
- JLabel lblPuntajeMsAlto = new JLabel("Puntaje m\u00E1s alto :");
- lblPuntajeMsAlto.setBounds(462, 11, 122, 34);
- panelMenu.add(lblPuntajeMsAlto);
- JTextPane textPane = new JTextPane();
- textPane.setBounds(449, 53, 135, 65);
- panelMenu.add(textPane);
- // ******************************************************************
- //ELEMENTOS DE OPCIONES
- JButton btnNewButton = new JButton("Tama\u00F1o del Tablero");
- btnNewButton.setFont(new Font("Tahoma", Font.PLAIN, 35));
- btnNewButton.setBackground(new Color(100, 149, 237));
- btnNewButton.setBounds(100, 27, 400, 110);
- panelOpc.add(btnNewButton);
- JButton btnx = new JButton("3X3");
- btnx.setBackground(new Color(100, 149, 237));
- btnx.setFont(new Font("Tahoma", Font.PLAIN, 25));
- btnx.setBounds(110, 148, 100, 50);
- panelOpc.add(btnx);
- JButton btnx_1 = new JButton("4X4");
- btnx_1.setBackground(new Color(100, 149, 237));
- btnx_1.setFont(new Font("Tahoma", Font.PLAIN, 25));
- btnx_1.setBounds(250, 148, 100, 50);
- panelOpc.add(btnx_1);
- JButton btnx_2 = new JButton("5X5");
- btnx_2.setFont(new Font("Tahoma", Font.PLAIN, 25));
- btnx_2.setBackground(new Color(100, 149, 237));
- btnx_2.setBounds(382, 148, 100, 50);
- panelOpc.add(btnx_2);
- JButton btnx_3 = new JButton("6X6");
- btnx_3.setFont(new Font("Tahoma", Font.PLAIN, 25));
- btnx_3.setBackground(new Color(100, 149, 237));
- btnx_3.setBounds(110, 240, 100, 50);
- panelOpc.add(btnx_3);
- JButton btnx_4 = new JButton("7X7");
- btnx_4.setFont(new Font("Tahoma", Font.PLAIN, 25));
- btnx_4.setBackground(new Color(100, 149, 237));
- btnx_4.setBounds(250, 240, 100, 50);
- panelOpc.add(btnx_4);
- JButton btnx_5 = new JButton("8X8");
- btnx_5.setFont(new Font("Tahoma", Font.PLAIN, 25));
- btnx_5.setBackground(new Color(100, 149, 237));
- btnx_5.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
- }
- });
- btnx_5.setBounds(382, 240, 100, 50);
- panelOpc.add(btnx_5);
- JButton btnx_6 = new JButton("9X9");
- btnx_6.setBackground(new Color(100, 149, 237));
- btnx_6.setFont(new Font("Tahoma", Font.PLAIN, 25));
- btnx_6.setBounds(170, 320, 100, 50);
- panelOpc.add(btnx_6);
- JButton btnx_7 = new JButton("10X10");
- btnx_7.setFont(new Font("Tahoma", Font.PLAIN, 20));
- btnx_7.setBackground(new Color(100, 149, 237));
- btnx_7.setBounds(329, 322, 100, 50);
- panelOpc.add(btnx_7);
- JLabel lblTeDesafiamosA = new JLabel("Te desafiamos a que ganes en los distintos tableros , si lo haces seras redirigido a un video porno espectacular");
- lblTeDesafiamosA.setBounds(20, 383, 564, 67);
- panelOpc.add(lblTeDesafiamosA);
- }
- public static void musicaFondo(Object multiTab) throws UnsupportedAudioFileException, IOException, LineUnavailableException
- {
- URL url = multiTab.getClass().getResource("sonidos/fondo.wav");
- AudioInputStream sound = AudioSystem.getAudioInputStream(url);
- Clip clip = AudioSystem.getClip();
- clip.open(sound);
- clip.start();
- clip.loop(Clip.LOOP_CONTINUOUSLY);
- }
- private String Highscore () throws FileNotFoundException{
- String ret = "";
- FileReader readFile = null ;
- BufferedReader reader =null;
- //formato = Jorge: 666
- try {
- readFile = new FileReader ("ranking.dat");
- reader = new BufferedReader (readFile);
- return reader.readLine();
- } catch (Exception e) {
- ret = "0" ;
- }
- finally{
- try {
- reader.close();
- } catch (Exception e2) {
- e2.printStackTrace();
- }
- }
- return ret ;
- }
- }
Add Comment
Please, Sign In to add comment