Guest User

Untitled

a guest
Apr 20th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.19 KB | None | 0 0
  1. use javax.swing.*;
  2.  
  3. public class FramePrincipal extends JFrame implements ActionListener
  4. {
  5.  
  6.     JMenuBar menu;
  7.     JMenu menuCliente;
  8.     JMenuItem cliCadastrar;
  9.     JDesktop desktop;
  10.  
  11.     public FramePrincipal(){
  12.         this.setSize(300, 300);
  13.         this.setDefaultCloseOperation(EXIT_ON_CLOSE);
  14.         this.setLocationRelativeTo(null);
  15.         this.getContentPane().setBackground(Color.WHITE);
  16.         this.setResizable(false);
  17.         this.setLayout(null);
  18.         this.setTitle("Painel Principal");
  19.         this.desktop = new JDesktop();
  20.                 this.getContentPane().add(desktop);
  21.  
  22.         this.menu = new JMenuBar();
  23.         this.cliCadastrar = new JMenuItem("Cadastrar Cliente");
  24.         this.menuCliente = new JMenu("Cliente");
  25.         this.menuCliente.add(this.cliCadastrar);
  26.         this.cliCadastrar.addActionListener(this);
  27.         this.menu.add(this.menuCliente);
  28.  
  29.         this.setJMenuBar(this.menu);
  30.     }
  31.  
  32.     @Override
  33.     public void actionPerformed(ActionEvent e) {
  34.        
  35.         if(e.getSource() == this.cliCadastrar){
  36.             /**
  37.             *   Vamos dizer que a JInternalFrame a ser chamada é
  38.             *   CadastrarCliente (nome da classe)
  39.             **/
  40.             CadastrarCliente cc = new CadastrarCliente();
  41.             desktop.add(cc); //Adiciona o InternalFrame no Desktop
  42.             cc.show();
  43.         }
  44.        
  45.     }
  46.  
  47. }
Add Comment
Please, Sign In to add comment