Guest User

Untitled

a guest
Nov 11th, 2013
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.32 KB | None | 0 0
  1. package gui;
  2.  
  3. import java.awt.BorderLayout;
  4. import java.awt.Component;
  5. import java.awt.GridLayout;
  6. import java.awt.event.ActionEvent;
  7. import java.awt.event.ActionListener;
  8.  
  9. import javax.swing.JButton;
  10. import javax.swing.JFrame;
  11. import javax.swing.JLabel;
  12. import javax.swing.JPanel;
  13. import javax.swing.SwingConstants;
  14. import javax.swing.SwingUtilities;
  15.  
  16. import utiles.SwingConsole;
  17.  
  18. public class MenuInicio extends JFrame{
  19.  
  20.     private JLabel accion = new JLabel("Selecione una Acción");
  21.    
  22.     private JButton botonNuevo = new JButton("Nuevo Juego");
  23.     private JButton botonCargar = new JButton("Cargar Juego");
  24.    
  25.     public MenuInicio(){
  26.        
  27.        
  28.         accion.setHorizontalAlignment(SwingConstants.CENTER);
  29.         add(accion,BorderLayout.NORTH);
  30.        
  31.         JPanel panelBotones = new JPanel(new GridLayout(1,2));
  32.         panelBotones.add(botonNuevo);
  33.         panelBotones.add(botonCargar);
  34.         add(panelBotones);
  35.        
  36.         botonNuevo.addActionListener(new ActionListener(){
  37.             public void actionPerformed(ActionEvent ev){
  38.                
  39.                 Component component = (Component) ev.getSource();
  40.                 JFrame frame = (JFrame) SwingUtilities.getRoot(component);
  41.                 inicializarMenuJuegoNuevo(frame);
  42.                
  43.             }
  44.         });
  45.        
  46.        
  47.     }
  48.    
  49.     private void inicializarMenuJuegoNuevo(JFrame j){
  50.        
  51.         SwingConsole.run(new MenuNuevoJuego(), 300, 150, true);
  52.         j.dispose();
  53.     }
  54.    
  55. }
Advertisement
Add Comment
Please, Sign In to add comment