Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.00 KB | None | 0 0
  1. package Telas;
  2. import javax.swing.JFrame;
  3. import javax.swing.JPanel;
  4. import javax.swing.JButton;
  5. import javax.swing.JTextField;
  6. import javax.swing.JLabel;
  7. import java.awt.Color;
  8. import javax.swing.border.LineBorder;
  9. import java.awt.event.ActionListener;
  10. import java.awt.event.ActionEvent;
  11. import javax.swing.JOptionPane;
  12. public class TelaInicial extends JPanel implements ActionListener{
  13.  
  14.     private JPanel painel;
  15.     private JButton botao;
  16.     private JButton botao1;
  17.     private JButton botao2;
  18.     private JTextField nome;
  19.     private JLabel label_nome;
  20.     private JLabel bem_vindo;
  21.  
  22.     public TelaInicial(){
  23.    
  24.         //super("Óticas HonoChik");
  25.         //this.setVisible(true);
  26.         ////            ( X   Y  LARGURA, ALTURA)
  27.         //this.setBounds(500,500,345,385);
  28.         //this.setDefaultCloseOperation(EXIT_ON_CLOSE);
  29.         //this.setLocationRelativeTo(null);
  30.         this.setContentPane(getPainel());
  31.         //this.repaint();
  32.         addEventos();
  33.        
  34.     }
  35.         public void addEventos(){
  36.             getBotao().addActionListener(this);
  37.             getBotao1().addActionListener(this);
  38.             getBotao2().addActionListener(this);
  39.     }
  40.  
  41.     public JPanel getPainel(){
  42.         if(painel==null){
  43.             painel = new JPanel();
  44.             painel.setLayout(null);
  45.             painel.add(getBotao());
  46.             painel.add(getBotao1());
  47.             painel.add(getBotao2());
  48.             painel.add(getJLabelBemVindo());
  49.             painel.setBackground(new Color(61, 21, 30));
  50.             painel.repaint();
  51.            
  52.         }
  53.             return painel;
  54.        
  55.     }
  56.  
  57.     public JButton getBotao(){
  58.         if(botao == null){
  59.             botao = new JButton();
  60.             botao.setBounds(50,120,100,50);
  61.             botao.setForeground(new Color(255,255,255));
  62.             botao.setBackground(new Color(126, 43, 51));
  63.             botao.setText("Evelin");
  64.             botao.setBorder(new LineBorder(new Color(126, 43, 51), 2, true));
  65.  
  66.         }
  67.        
  68.         return botao;
  69.     }
  70.  
  71.     public JButton getBotao1(){
  72.         if(botao1 ==null){
  73.             botao1 = new JButton();
  74.             botao1.setBounds(50,190,100,50);
  75.             botao1.setForeground(new Color(255,255,255));
  76.             botao1.setBackground(new Color(126, 43, 51));
  77.             botao1.setText("Josimar");
  78.             botao1.setBorder(new LineBorder(new Color(126, 43, 51), 2, true));
  79.         }
  80.        
  81.         return botao1;
  82.     }
  83.  
  84.     public JButton getBotao2(){
  85.         if(botao2 ==null){
  86.             botao2 = new JButton();
  87.             botao2.setBounds(50,260,100,50);
  88.             botao2.setForeground(new Color(255,255,255));
  89.             botao2.setBackground(new Color(126, 43, 51));
  90.             botao2.setText("Diego");
  91.             botao2.setBorder(new LineBorder(new Color(126, 43, 51), 2, true));
  92.         }
  93.        
  94.         return botao2;
  95.     }
  96.    
  97.     public JLabel getJLabelBemVindo(){
  98.         if(bem_vindo == null){
  99.             bem_vindo = new JLabel("Bem vindo à Óticas HonoChick");
  100.             bem_vindo.setForeground(new Color(255,255,255));
  101.             bem_vindo.setBounds(70,0,200,100);
  102.         }
  103.          return bem_vindo;
  104.     }
  105.  
  106.     public void actionPerformed(ActionEvent e){
  107.         if(e.getSource() == getBotao()){
  108.             JOptionPane.showMessageDialog(null,"Vendedora Evelin");
  109.         }
  110.         if(e.getSource() == getBotao1()){
  111.             JOptionPane.showMessageDialog(null,"Vendedora Josimar");
  112.         }
  113.         if(e.getSource() == getBotao2()){
  114.             JOptionPane.showMessageDialog(null,"Vendedora Diego");
  115.         }
  116.     }
  117.  
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement