Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.55 KB | None | 0 0
  1. import java.awt.BorderLayout;
  2. import java.awt.CardLayout;
  3.  
  4. import javax.swing.ImageIcon;
  5. import javax.swing.JLabel;
  6. import javax.swing.JOptionPane;
  7. import javax.swing.JPanel;
  8.  
  9.  
  10. public class Controlador {
  11.  
  12.     private TelaPCs Guia;
  13.     private TelaInfoMais infomais;
  14.     private TelaCadastroPC telaCadastroPC;
  15.     private TelaPrincipal telaPrincipal;
  16.  
  17.     private JLabel Logo;
  18.     private JPanel telaLimpa;
  19.    
  20.     private CardLayout cardLayout;
  21.    
  22.     public Controlador(TelaPrincipal parent, CardLayout cardLayout){
  23.         this.cardLayout = cardLayout;
  24.        
  25.        
  26.         telaPrincipal = parent;
  27.         telaPrincipal.setLayout(cardLayout);
  28.        
  29.         telaLimpa = new JPanel();
  30.         telaPrincipal.add(telaLimpa, "telaLimpa");
  31.         Logo = new JLabel(new ImageIcon("src/Logo.png"));
  32.         telaLimpa.setLayout(new BorderLayout());
  33.         telaLimpa.add(Logo, BorderLayout.NORTH);
  34.        
  35.         telaCadastroPC = new TelaCadastroPC(this);
  36.         telaPrincipal.add(telaCadastroPC, "telaCadastroPC");
  37.        
  38.         Guia = new TelaPCs(this);
  39.         telaPrincipal.add(Guia, "Guia");
  40.    
  41.        
  42.         cardLayout.show(telaPrincipal.getContentPane(), "telaLimpa");
  43.        
  44.     }
  45.     public void MostrarTelaLimpa(){
  46.        
  47.         cardLayout.show(telaPrincipal.getContentPane(), "telaLimpa");
  48.        
  49.     }
  50.    
  51.     public void MostrarTelaCadastroPC(){
  52.         cardLayout.show(telaPrincipal.getContentPane(), "telaCadastroPC"); 
  53.        
  54.     }
  55.    
  56.    
  57.     public void mostrarGuia(){
  58.     cardLayout.show(telaPrincipal.getContentPane(), "Guia");
  59.     }
  60.    
  61.    
  62.     public void sair(){
  63.        
  64.         int opt = JOptionPane.showConfirmDialog(telaPrincipal, "Deseja sair?", "Sair", JOptionPane.YES_NO_OPTION);
  65.         if(opt == JOptionPane.YES_OPTION){
  66.                     System.exit(0);
  67.                    
  68.         }
  69.        
  70.         }
  71.    
  72.  
  73.    
  74.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement