Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.16 KB | None | 0 0
  1. import java.awt.BorderLayout;
  2. import java.awt.Dimension;
  3. import java.awt.Toolkit;
  4. import java.awt.event.ActionEvent;
  5. import java.awt.event.ActionListener;
  6.  
  7. import javax.swing.JButton;
  8. import javax.swing.JFrame;
  9. import javax.swing.JLabel;
  10.  
  11.  
  12. public class TelaInfoMais extends JFrame implements ActionListener{
  13.  
  14.     JButton btnFechar;
  15.     JLabel nome;
  16.     JLabel CNPJ;
  17.     JLabel endereco;
  18.    
  19.    
  20.     public TelaInfoMais(){
  21.         super("Mais Informações");
  22.        
  23.        
  24.         this.setLayout(new BorderLayout());
  25.        
  26.         btnFechar = new JButton("Fechar");
  27.         btnFechar.addActionListener(this);
  28.         btnFechar.setPreferredSize(new Dimension(30,30));
  29.        
  30.        
  31.        
  32.         this.setDefaultCloseOperation(EXIT_ON_CLOSE);
  33.  
  34.         //Código para executar no meio da tela
  35.        
  36.         int width = Toolkit.getDefaultToolkit().getScreenSize().width;
  37.         int height = Toolkit.getDefaultToolkit().getScreenSize().height;
  38.        
  39.         this.setBounds((width - 450) /2, (height - 300) /2,450,300);
  40.        
  41.         // Fim do código
  42.        
  43.        
  44.         this.add(btnFechar, BorderLayout.SOUTH);
  45.         this.setVisible(true);
  46.     }
  47.    
  48.    
  49.  
  50.     @Override
  51.     public void actionPerformed(ActionEvent e) {
  52.         // TODO Auto-generated method stub
  53.        
  54.         if(e.getSource() == btnFechar){
  55.             System.exit(0);
  56.         }
  57.        
  58.     }
  59.    
  60.    
  61.    
  62.    
  63.    
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement