Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use javax.swing.*;
- public class FramePrincipal extends JFrame implements ActionListener
- {
- JMenuBar menu;
- JMenu menuCliente;
- JMenuItem cliCadastrar;
- JDesktop desktop;
- public FramePrincipal(){
- this.setSize(300, 300);
- this.setDefaultCloseOperation(EXIT_ON_CLOSE);
- this.setLocationRelativeTo(null);
- this.getContentPane().setBackground(Color.WHITE);
- this.setResizable(false);
- this.setLayout(null);
- this.setTitle("Painel Principal");
- this.desktop = new JDesktop();
- this.getContentPane().add(desktop);
- this.menu = new JMenuBar();
- this.cliCadastrar = new JMenuItem("Cadastrar Cliente");
- this.menuCliente = new JMenu("Cliente");
- this.menuCliente.add(this.cliCadastrar);
- this.cliCadastrar.addActionListener(this);
- this.menu.add(this.menuCliente);
- this.setJMenuBar(this.menu);
- }
- @Override
- public void actionPerformed(ActionEvent e) {
- if(e.getSource() == this.cliCadastrar){
- /**
- * Vamos dizer que a JInternalFrame a ser chamada é
- * CadastrarCliente (nome da classe)
- **/
- CadastrarCliente cc = new CadastrarCliente();
- desktop.add(cc); //Adiciona o InternalFrame no Desktop
- cc.show();
- }
- }
- }
Add Comment
Please, Sign In to add comment