Advertisement
Guest User

Untitled

a guest
Apr 21st, 2011
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.17 KB | None | 0 0
  1. package uniandes.cupi2.crucero.interfaz;
  2.  
  3. import java.*;
  4. import java.awt.*;
  5.  
  6. import javax.swing.Icon;
  7. import javax.swing.JFrame;
  8. import javax.swing.JOptionPane;
  9.  
  10. import uniandes.cupi2.crucero.mundo.Crucero;
  11. import uniandes.cupi2.crucero.mundo.Destino;
  12.  
  13. class InterfazCrusero extends JFrame {
  14.  
  15.     private InterfazCrusero interfazCrusero;
  16.     private PanelDestino panelDestino;
  17.     private PanelOpcion panelOpcion;
  18.     private PanelTitulo panelTitulo;
  19.     private Crucero crusero;
  20.    
  21.    
  22.     public InterfazCrusero() {
  23.     try{
  24.        
  25.         setTitle("Cruseros Cupi2");
  26.         setSize(700, 550);
  27.         setForeground(Color.blue);
  28.  
  29.         panelTitulo = new PanelTitulo();
  30.         panelTitulo.setSize(600, 100);
  31.         add(panelTitulo, BorderLayout.NORTH);
  32.  
  33.         panelDestino = new PanelDestino();
  34.         add(panelDestino, BorderLayout.CENTER);
  35.        
  36.         panelOpcion = new PanelOpcion();
  37.         add(panelOpcion, BorderLayout.SOUTH);
  38.  
  39.        
  40.     }catch(Exception e){
  41.         String mensaje=e.getMessage();
  42.          JOptionPane.showMessageDialog(this, mensaje, "Error",  JOptionPane.ERROR_MESSAGE);
  43.     }
  44.     }
  45.  
  46.     public static void main(String[] args) {
  47.         InterfazCrusero ventana = new InterfazCrusero();
  48.         ventana.setVisible(true);
  49.        
  50.     }
  51.    
  52.     public Destino darDestino(){
  53.     return crusero.darDestinoActual();
  54.     }
  55.    
  56.    
  57.    
  58.    
  59.     public Icon imagenAnterior()throws Exception{
  60.         return  crusero.darImagenAnteriorDelDestinoActual().darImagen();
  61.     }
  62.    
  63.     public Icon imagenSiguiente()throws Exception{
  64.         return crusero.darImagenSiguienteDelDestinoActual().darImagen();
  65.     }
  66.    
  67.     public Icon imagenActual() throws Exception{
  68.         return  crusero.darImagenDestinoActual().darImagen();
  69.     }
  70.    
  71.    
  72.     public Destino destinoActual(){
  73.         return crusero.darDestinoActual();
  74.     }
  75.    
  76.    
  77.    
  78.    
  79.    
  80.    
  81.    
  82.    
  83.    
  84.    
  85.    
  86.    
  87.    
  88.    
  89.    
  90.    
  91.    
  92.    
  93.    
  94.    
  95.    
  96.    
  97.    
  98.    
  99.    
  100.    
  101.    
  102.    
  103.     public void reqFuncOpcion1( ){
  104.         String mensaje=crusero.metodo1();
  105.         JOptionPane.showMessageDialog(this,mensaje, "Respuesta",  JOptionPane.INFORMATION_MESSAGE);
  106.        
  107.     }
  108.     public void reqFuncOpcion2( ){
  109.         String mensaje=crusero.metodo2();
  110.         JOptionPane.showMessageDialog(this, mensaje, "repuesta",JOptionPane.INFORMATION_MESSAGE);
  111.     }
  112. }
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.     private JButton butImgAnte;
  137.     private JButton butImssig;
  138.  
  139.    
  140.     private InterfazCrusero principal;
  141.     private PanelDestino panelDestino;
  142.     private PanelOpciones panelOpciones;
  143.     public PanelDestino(){
  144.        
  145.        
  146.         TitledBorder border=BorderFactory.createTitledBorder("Imagenes del destino");
  147.         setBorder(border);
  148.        
  149.                
  150.         lblReferencia=new JLabel (principal.destinoActual().darPais()+"-"+principal.destinoActual().darCiudad());
  151.        
  152.         add(lblReferencia ,BorderLayout.NORTH);
  153.        
  154.             lblImagen=new JLabel ("");
  155.         lblImagen.setIcon(darFoto());
  156.         lblImagen.setPreferredSize(new Dimension(300,250));
  157.         add(lblImagen,BorderLayout.CENTER);
  158.        
  159.    
  160.         butImgAnte=new JButton (IMAGEN_ANTERIOR);
  161.         butImgAnte.setActionCommand(IMAGEN_ANTERIOR);
  162.         butImgAnte.addActionListener(this);
  163.         butImgAnte.setPreferredSize(new Dimension(100,100));
  164.         add(butImgAnte,BorderLayout.EAST);
  165.        
  166.    
  167.        
  168.            
  169.         butImssig=new JButton (IMAGEN_SIGUIENTE);
  170.         butImssig.setActionCommand(IMAGEN_SIGUIENTE);
  171.         butImssig.addActionListener(this);
  172.         butImssig.setPreferredSize(new Dimension(100,100));
  173.         add(butImssig,BorderLayout.EAST);
  174.        
  175.         vacio=new JLabel ();
  176.         add(vacio);
  177.        
  178.         panelOpciones = new PanelOpciones();
  179.         panelOpciones.setSize(400, 200);
  180.         add(panelOpciones, BorderLayout.SOUTH);
  181.     }
  182.    
  183.    
  184.    
  185.    
  186.    
  187.    
  188.    
  189.    
  190.     public Icon darFoto() {
  191.         try{
  192.         return principal.imagenActual();
  193.     }catch (Exception e){
  194.         JOptionPane.showMessageDialog(this,e.getMessage() , "Error",  JOptionPane.ERROR_MESSAGE);
  195.         return null;
  196.     }
  197.        
  198.     }
  199.    
  200.      public void actionPerformed( ActionEvent e ){
  201.          String d =e.getActionCommand();
  202.          try{
  203.                if(d.equals(IMAGEN_ANTERIOR ))
  204.                 {
  205.                    
  206.                    
  207.                 lblImagen.setIcon(principal.imagenAnterior());
  208.                    
  209.                                    
  210.                 }
  211.                else if(d.equals(IMAGEN_SIGUIENTE)){
  212.                    
  213.                    lblImagen.setIcon(principal.imagenSiguiente());
  214.                  }
  215.          }catch (Exception a){
  216.             String mensaje=a.getMessage();
  217.              JOptionPane.showMessageDialog(this, mensaje, "INFORMACION",  JOptionPane.INFORMATION_MESSAGE);
  218.          }
  219.      }
  220.    
  221. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement