/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package telas;
import javax.swing.JOptionPane;
/**
*
* @author silas
*/
public class MenuPrincipal extends javax.swing.JFrame {
/**
* Creates new form MenuPrincipal
*/
private TelaInicial telaAnterior;
private MenuDiretor menuDiretor;
private static int opçãoMenuPrincipal;
private static String senhaDiretor, senhaSecretário;
public static String getSenhaSecretário() {
return senhaSecretário;
}
public static String getSenhaDiretor() {
return senhaDiretor;
}
public static int getOpçãoMenuPrincipal() {
return opçãoMenuPrincipal;
}
public MenuDiretor getMenuDiretor() {
return menuDiretor;
}
private MenuPrincipal() {
initComponents();
}
public MenuPrincipal(TelaInicial telaAnterior)
{
//para chamar construtor padrao
this();
this.telaAnterior=telaAnterior;
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Escola Ensino Fundamental");
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
jLabel1.setText("Menu Principal");
jButton1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
jButton1.setText("Area do diretor");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
jButton2.setText("Area do secretário");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton3.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
jButton3.setText("Area do professor");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jButton4.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
jButton4.setText("Area do alunor");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
jButton5.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
jButton5.setText("Sair");
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(70, 70, 70)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jButton1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGap(54, 54, 54)
.addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(527, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(73, 73, 73)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(33, 33, 33)
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton4)
.addGap(73, 73, 73)
.addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(112, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
System.exit(0);
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
opçãoMenuPrincipal=1;
// TODO add your handling code here:
this.setEnabled(false);// desabilita tela atual para nao ser clicada
// botao cadastrar pressionado
// if()
menuDiretor =new MenuDiretor(this);
senhaDiretor=JOptionPane.showInputDialog("Entre com a senha sr diretor");
// System.out.println("A entrada foi"+senha);
//JOptionPane.showMessageDialog(null, "cadastro realizado com sucesso. " + senha); senha = new String(jPasswordField1.getPassword());
//deu certo, agora colocar uma coisa para senha errada
if(senhaDiretor.equals(telaAnterior.getSenha()))
{
menuDiretor.setVisible(true);
}
else
{
JOptionPane.showMessageDialog(null, "senha errada, tente novamente ");
this.setEnabled(true);
}
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(MenuDiretor.getNomeSe()==null &&MenuDiretor.getCpfSe()==null&&MenuDiretor.getSenhaSe()==null&&MenuDiretor.getDataNascimentoSe()==null)
{
JOptionPane.showMessageDialog(null, "Não existe secretário cadastrado ");
}
else{
opçãoMenuPrincipal=2;
this.setEnabled(false);// desabilita tela atual para nao ser clicada
// botao cadastrar pressionado
MenuSecretário menuSecretário =new MenuSecretário(this);
senhaSecretário=JOptionPane.showInputDialog("Entre com a senha sr secretário");
if(senhaSecretário.equals(telaAnterior.getSenha()))//colocar a senha do secretario aki
{
menuSecretário.setVisible(true);
}
else
{
JOptionPane.showMessageDialog(null, "senha errada, tente novamente ");
this.setEnabled(true);
}
}
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
opçãoMenuPrincipal=3;
this.setEnabled(false);// desabilita tela atual para nao ser clicada
// botao cadastrar pressionado
new MenuProfessor(this).setVisible(true);
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
opçãoMenuPrincipal=4;
this.setEnabled(false);// desabilita tela atual para nao ser clicada
// botao cadastrar pressionado
new MenuAluno(this).setVisible(true);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(MenuPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(MenuPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(MenuPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(MenuPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MenuPrincipal().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JLabel jLabel1;
// End of variables declaration
}