Package view

Source Code of view.FormPrincipal

/**
* gui
* 14/03/2008
* FormPrincipal.java
*/
package view;

import java.beans.PropertyVetoException;
import java.util.logging.Level;
import java.util.logging.Logger;
import view.componentes.MainMenu;
import view.componentes.StatusBar;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JPanel;

import controller.operating.GerenciadorOperacional;
import controller.operating.Strings;
import javax.swing.JInternalFrame;
import org.jscroll.JScrollDesktopPane;

/**
* @author Iniciacao Cientifica
*
*/
public class FormPrincipal {

    private JFrame jFrame = null//  @jve:decl-index=0:visual-constraint="10,42"

    private MainMenu menuPrincipal = null//  @jve:decl-index=0:visual-constraint="381,10"

    private JScrollDesktopPane jDesktopPane = null;
    private JPanel jContentPane = null;
    private StatusBar statusBar = null//  @jve:decl-index=0:visual-constraint="10,10"


    public FormPrincipal(boolean maximized) {
        getJFrame(maximized);
    }

    /**
     * This method initializes JFrame
     *
     * @return javax.swing.JFrame
     */
    private JFrame getJFrame(boolean maximized) {
        if (jFrame == null) {
            jFrame = new JFrame();
            if (maximized) {
                jFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
            }
            jFrame.setTitle(Strings.version);
            jFrame.setSize(640, 700);
            jFrame.setJMenuBar(getMenuPrincipal());
            jFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
            jFrame.setContentPane(getContentPane());
            jFrame.addWindowListener(new WindowAdapter() {
                @Override
                public void windowClosing(WindowEvent e) {
                    GerenciadorOperacional.closeFramePrincipal();
                }
               
                @Override
                public void windowIconified(WindowEvent e){
                    GerenciadorOperacional.setVisibleFramePrincipal(true);
                }
               
            });
            jFrame.setLocationRelativeTo(null);
            jFrame.setVisible(true);
        }
        return jFrame;
    }

    public JFrame getJFrame() {
        return jFrame;
    }

    /**
     * This method initializes jPanel 
     *  
     * @return javax.swing.JPanel 
     */
    private JPanel getContentPane() {
        if (jContentPane == null) {
            jContentPane = new JPanel();
            jContentPane.setBackground(new Color(102, 102, 102));
            jContentPane.setLayout(new BorderLayout());
            jContentPane.add(getJDesktopPane(), BorderLayout.CENTER);
            jContentPane.add(getStatusBar(), BorderLayout.SOUTH);
        }

        return jContentPane;
    }

    /**
     * This method initializes Menu
     *
     * @return javax.swing.JPanel
     */
    private MainMenu getMenuPrincipal() {
        if (menuPrincipal == null) {
            menuPrincipal = new MainMenu();
            menuPrincipal.setSize(new Dimension(164, 22));
            menuPrincipal.getItemMenuCandidato().addActionListener(
                    new ActionListener() {

                        public void actionPerformed(ActionEvent e) {
                            CandidatoView candidatoView = new CandidatoView();
                            GerenciadorOperacional.addFrame(candidatoView);
                        }
                    });
            menuPrincipal.getItemMenuDocente().addActionListener(
                    new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        DocenteView docenteView = new DocenteView();
                        GerenciadorOperacional.addFrame(docenteView);
                    }
            });
            menuPrincipal.getItemMenuAluno().addActionListener(
                    new ActionListener() {

                        public void actionPerformed(ActionEvent e) {
                            AlunoView alunoView = new AlunoView();
                            GerenciadorOperacional.addFrame(alunoView);

                        }
                    });
            menuPrincipal.getItemMenuEstagiario().addActionListener(
                    new ActionListener() {

                        public void actionPerformed(ActionEvent e) {
                            EstagiarioView estagiarioView = new EstagiarioView();
                            GerenciadorOperacional.addFrame(estagiarioView);
                        }
                    });
            menuPrincipal.getItemMenuEmpresa().addActionListener(
                    new ActionListener() {

                        public void actionPerformed(ActionEvent e) {
                            EmpresaView empresaView = new EmpresaView();
                            GerenciadorOperacional.addFrame(empresaView);

                        }
                    });
            menuPrincipal.getItemMenuEstagio().addActionListener(
                    new ActionListener() {

                        public void actionPerformed(ActionEvent e) {
                            EstagioView estagioView = new EstagioView();
                            GerenciadorOperacional.addFrame(estagioView);
                        }
                    });
            menuPrincipal.getItemMenuContato().addActionListener(
                    new ActionListener() {

                        public void actionPerformed(ActionEvent e) {
                            ContatoView contatoView = new ContatoView();
                            GerenciadorOperacional.addFrame(contatoView);
                        }
                    });
            menuPrincipal.getItemMenuAulaAvaliativa().addActionListener(
                    new ActionListener() {

                        public void actionPerformed(ActionEvent e) {
                            AulaAvaliativaView entrevistaView = new AulaAvaliativaView();
                            GerenciadorOperacional.addFrame(entrevistaView);
                        }
                    });
            menuPrincipal.getItemMenuAvaliacao().addActionListener(
                    new ActionListener() {

                        public void actionPerformed(ActionEvent e) {
                            AvaliacaoView avaliacaoView = new AvaliacaoView();
                            GerenciadorOperacional.addFrame(avaliacaoView);
                        }
                    });
             menuPrincipal.getItemMenuFormulario().addActionListener(
                    new ActionListener() {

                        public void actionPerformed(ActionEvent e) {
                            FormularioView formularioView = new FormularioView("0", "0", "Navegacao");
                            GerenciadorOperacional.addFrame(formularioView);
                        }
                    });
            menuPrincipal.getItemMenuOptions().addActionListener(
                    new ActionListener() {

                        public void actionPerformed(ActionEvent e) {
                            FormOpcoes opcoesView = new FormOpcoes();
                            GerenciadorOperacional.addFrame(opcoesView);
                        }
                    });
            menuPrincipal.getItemMenuSobre().addActionListener(
                    new ActionListener() {

                        public void actionPerformed(ActionEvent e) {
                            FormSobre sobreView = new FormSobre();
                            sobreView.setLocationRelativeTo(null);
                            sobreView.setVisible(true);
                        }
                    });

            menuPrincipal.getItemMenuSair().addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent e) {
                    GerenciadorOperacional.closeFramePrincipal();
                }
            });
        }
        return menuPrincipal.build();
    }

    /**
     * This method initializes jDesktopPane
     *
     * @return javax.swing.JDesktopPane
     */
    private JScrollDesktopPane getJDesktopPane() {
        if (jDesktopPane == null) {
            jDesktopPane = new JScrollDesktopPane();
        }
        return jDesktopPane;
    }

    private StatusBar getStatusBar() {
        if (statusBar == null) {
            statusBar = new StatusBar();
        }
        return statusBar;
    }

    /**
     * This method finalize jFrame
     *
     * @return void
     */
    public void close() {
        jFrame.dispose();
    }

    /**
     * This method remove a jInternalFrame
     *
     * @return void
     */
    public void removeFrame() {
        JInternalFrame jInternalFrame = jDesktopPane.getSelectedFrame();
        jDesktopPane.remove(jInternalFrame);
    }

    /**
     * This method set a Visibility do jFrame
     *
     * @return void
     */
    public void setVisible(boolean visible) {
        jFrame.setVisible(visible);
    }

    /**
     * This method add a jInternalFrame
     *
     * @return void
     */
    public void addFrame(JInternalFrame jInternalFrame) {
        jInternalFrame.setVisible(true);
        jDesktopPane.add(jInternalFrame);       
        try {
            jInternalFrame.setSelected(true);
        } catch (PropertyVetoException ex) {
            Logger.getLogger(FormPrincipal.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
TOP

Related Classes of view.FormPrincipal

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.