Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Pedroalves

[Resolvido] erro a passar jframe para jpanel

Recommended Posts

no aviao2.java

segue-se o codigo

package Gestao_Rotas;

import HelperDB.DBAccessObj;
import classes.Aviao;
import java.math.BigDecimal;
import java.sql.SQLException;
import javax.swing.JFrame;
import javax.swing.JPanel;


/**
*
* @author Alves
*/
public class aviao2 extends javax.swing.JPanel {
private JPanel previousPanel = null;
   JFrame parent = null;

private DBAccessObj dbo;
   /**
    * Creates new form aviao2
    */
   public aviao2(JFrame fparent, JPanel previousPanel, DBAccessObj dbo) {

       initComponents();
       this.parent = fparent;
       this.previousPanel = previousPanel;
       this.dbo = dbo;
       this.menu.setVisible(true);
      this.setSize(542, 500);
       inserir_aviao.setVisible(false);
       listamenu.setVisible(false);
       elimina.setVisible(false);
       altera.setVisible(false);
   }

   /**
    * 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() {

       pesquisa = new javax.swing.JPanel();
       menu = new javax.swing.JPanel();
       jButton1 = new javax.swing.JButton();
       jButton4 = new javax.swing.JButton();
       jButton5 = new javax.swing.JButton();
       jButton6 = new javax.swing.JButton();
       listamenu = new javax.swing.JPanel();
       jLabel2 = new javax.swing.JLabel();
       Pesquisa = new javax.swing.JTextField();
       jButton8 = new javax.swing.JButton();
       jScrollPane2 = new javax.swing.JScrollPane();
       jTable1 = new javax.swing.JTable();
       inserir_aviao = new javax.swing.JPanel();
       jLabel8 = new javax.swing.JLabel();
       Matricula = new javax.swing.JFormattedTextField();
       jLabel9 = new javax.swing.JLabel();
       Campanhia = new javax.swing.JTextField();
       jLabel10 = new javax.swing.JLabel();
       jButton2 = new javax.swing.JButton();
       jButton3 = new javax.swing.JButton();
       Capacidade = new javax.swing.JTextField();
       altera = new javax.swing.JPanel();
       jLabel1 = new javax.swing.JLabel();
       Pesquisa_altera = new javax.swing.JTextField();
       jScrollPane1 = new javax.swing.JScrollPane();
       jTable2 = new javax.swing.JTable();
       jButton10 = new javax.swing.JButton();
       jButton13 = new javax.swing.JButton();
       elimina = new javax.swing.JPanel();
       jLabel3 = new javax.swing.JLabel();
       Pesquisa_elimina = new javax.swing.JTextField();
       jButton11 = new javax.swing.JButton();
       jScrollPane3 = new javax.swing.JScrollPane();
       jTable3 = new javax.swing.JTable();
       jButton12 = new javax.swing.JButton();
       jLabel5 = new javax.swing.JLabel();
       jLabel6 = new javax.swing.JLabel();
       jPanel2 = new javax.swing.JPanel();
       Aviaos = new javax.swing.JButton();
       Piloto1 = new javax.swing.JButton();
       copiloto1 = new javax.swing.JButton();
       voo1 = new javax.swing.JButton();
       autorizacoes1 = new javax.swing.JButton();
       jButton9 = new javax.swing.JButton();
       jButton7 = new javax.swing.JButton();

       jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/PlusSign.png"))); // NOI18N
       jButton1.setText("Inserir");
       jButton1.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               jButton1ActionPerformed(evt);
           }
       });

       jButton4.setText("Listar");
       jButton4.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               jButton4ActionPerformed(evt);
           }
       });

       jButton5.setText("Apagar");

       jButton6.setText("Alterar");
       jButton6.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               jButton6ActionPerformed(evt);
           }
       });

       listamenu.setBounds(12,50, 329, 340);

       jLabel2.setText("Matricula");

       jButton8.setText("Pesquisar");
       jButton8.addMouseListener(new java.awt.event.MouseAdapter() {
           public void mouseClicked(java.awt.event.MouseEvent evt) {
               jButton8MouseClicked(evt);
           }
       });
       jButton8.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               jButton8ActionPerformed(evt);
           }
       });

       jTable1.setModel(new javax.swing.table.DefaultTableModel(
           new Object [][] {

           },
           new String [] {
               "IDAVIAO", "MATRICULA", "COMPANHIA", "CAPACIDADE"
           }
       ) {
           Class[] types = new Class [] {
               java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
           };
           boolean[] canEdit = new boolean [] {
               false, false, false, false, false, false
           };

           public Class getColumnClass(int columnIndex) {
               return types [columnIndex];
           }

           public boolean isCellEditable(int rowIndex, int columnIndex) {
               return canEdit [columnIndex];
           }
       });
       jScrollPane2.setViewportView(jTable1);

       javax.swing.GroupLayout listamenuLayout = new javax.swing.GroupLayout(listamenu);
       listamenu.setLayout(listamenuLayout);
       listamenuLayout.setHorizontalGroup(
           listamenuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(listamenuLayout.createSequentialGroup()
               .addGroup(listamenuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                   .addGroup(listamenuLayout.createSequentialGroup()
                       .addContainerGap()
                       .addComponent(jLabel2)
                       .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                       .addComponent(Pesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE)
                       .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                       .addComponent(jButton8)
                       .addGap(0, 0, Short.MAX_VALUE))
                   .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
               .addContainerGap())
       );
       listamenuLayout.setVerticalGroup(
           listamenuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(listamenuLayout.createSequentialGroup()
               .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
               .addGroup(listamenuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                   .addComponent(jLabel2)
                   .addComponent(Pesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                   .addComponent(jButton8))
               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
               .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addGap(296, 296, 296))
       );

       jLabel8.setText("Matricula");

       Matricula.setSize(109, 20);

       jLabel9.setText("Companhia");

       jLabel10.setText("Capacidade");

       jButton2.setText("Aceitar");
       jButton2.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               jButton2ActionPerformed(evt);
           }
       });

       jButton3.setText("Limpar");
       jButton3.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               jButton3ActionPerformed(evt);
           }
       });

       javax.swing.GroupLayout inserir_aviaoLayout = new javax.swing.GroupLayout(inserir_aviao);
       inserir_aviao.setLayout(inserir_aviaoLayout);
       inserir_aviaoLayout.setHorizontalGroup(
           inserir_aviaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(inserir_aviaoLayout.createSequentialGroup()
               .addContainerGap()
               .addComponent(jButton2)
               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
               .addComponent(jButton3)
               .addContainerGap())
           .addGroup(inserir_aviaoLayout.createSequentialGroup()
               .addGroup(inserir_aviaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                   .addGroup(inserir_aviaoLayout.createSequentialGroup()
                       .addComponent(jLabel8)
                       .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                       .addComponent(Matricula))
                   .addGroup(inserir_aviaoLayout.createSequentialGroup()
                       .addComponent(jLabel10)
                       .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                       .addComponent(Capacidade))
                   .addGroup(inserir_aviaoLayout.createSequentialGroup()
                       .addComponent(jLabel9)
                       .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                       .addComponent(Campanhia)))
               .addGap(0, 10, 10))
       );
       inserir_aviaoLayout.setVerticalGroup(
           inserir_aviaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(inserir_aviaoLayout.createSequentialGroup()
               .addGroup(inserir_aviaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                   .addComponent(jLabel8)
                   .addComponent(Matricula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
               .addGap(18, 18, 18)
               .addGroup(inserir_aviaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                   .addComponent(jLabel9)
                   .addComponent(Campanhia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
               .addGroup(inserir_aviaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                   .addComponent(jLabel10)
                   .addComponent(Capacidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
               .addGroup(inserir_aviaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                   .addComponent(jButton2)
                   .addComponent(jButton3))
               .addGap(291, 291, 291))
       );

       jLabel1.setText("Matricula");

       jTable2.setModel(new javax.swing.table.DefaultTableModel(
           new Object [][] {

           },
           new String [] {
               "IDAVIAO", "MATRICULA", "COMPANHIA", "CAPACIDADE"
           }
       ) {
           Class[] types = new Class [] {
               java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
           };
           boolean[] canEdit = new boolean [] {
               false, false, false, false, false, false
           };

           public Class getColumnClass(int columnIndex) {
               return types [columnIndex];
           }

           public boolean isCellEditable(int rowIndex, int columnIndex) {
               return canEdit [columnIndex];
           }
       });
       jScrollPane1.setViewportView(jTable2);

       jButton10.setText("Altera");
       jButton10.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               jButton10ActionPerformed(evt);
           }
       });

       jButton13.setText("jButton13");
       jButton13.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               jButton13ActionPerformed(evt);
           }
       });

       javax.swing.GroupLayout alteraLayout = new javax.swing.GroupLayout(altera);
       altera.setLayout(alteraLayout);
       alteraLayout.setHorizontalGroup(
           alteraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(alteraLayout.createSequentialGroup()
               .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
               .addGroup(alteraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                   .addComponent(jButton10)
                   .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 234, javax.swing.GroupLayout.PREFERRED_SIZE)
                   .addGroup(alteraLayout.createSequentialGroup()
                       .addComponent(jLabel1)
                       .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                       .addComponent(Pesquisa_altera, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                       .addGap(18, 18, 18)
                       .addComponent(jButton13))))
       );
       alteraLayout.setVerticalGroup(
           alteraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(alteraLayout.createSequentialGroup()
               .addContainerGap()
               .addGroup(alteraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                   .addComponent(jLabel1)
                   .addComponent(Pesquisa_altera, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                   .addComponent(jButton13))
               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
               .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
               .addComponent(jButton10)
               .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
       );

       jLabel3.setText("Matricula");

       jButton11.setText("Pesquisar");
       jButton11.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               jButton11ActionPerformed(evt);
           }
       });

       jTable3.setModel(new javax.swing.table.DefaultTableModel(
           new Object [][] {

           },
           new String [] {
               "IDAVIAO", "MATRICULA", "COMPANHIA", "CAPACIDADE"
           }
       ) {
           Class[] types = new Class [] {
               java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
           };
           boolean[] canEdit = new boolean [] {
               false, false, false, false, false, false
           };

           public Class getColumnClass(int columnIndex) {
               return types [columnIndex];
           }

           public boolean isCellEditable(int rowIndex, int columnIndex) {
               return canEdit [columnIndex];
           }
       });
       jScrollPane3.setViewportView(jTable3);

       jButton12.setText("Elimina");
       jButton12.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               jButton12ActionPerformed(evt);
           }
       });

       javax.swing.GroupLayout eliminaLayout = new javax.swing.GroupLayout(elimina);
       elimina.setLayout(eliminaLayout);
       eliminaLayout.setHorizontalGroup(
           eliminaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(eliminaLayout.createSequentialGroup()
               .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
               .addGroup(eliminaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                   .addGroup(eliminaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                       .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 234, javax.swing.GroupLayout.PREFERRED_SIZE)
                       .addGroup(eliminaLayout.createSequentialGroup()
                           .addComponent(jLabel3)
                           .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                           .addComponent(Pesquisa_elimina, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                           .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                           .addComponent(jButton11)))
                   .addComponent(jButton12)))
       );
       eliminaLayout.setVerticalGroup(
           eliminaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(eliminaLayout.createSequentialGroup()
               .addContainerGap()
               .addGroup(eliminaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                   .addComponent(jLabel3)
                   .addComponent(Pesquisa_elimina, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                   .addComponent(jButton11))
               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
               .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
               .addComponent(jButton12)
               .addContainerGap(58, Short.MAX_VALUE))
       );

       javax.swing.GroupLayout menuLayout = new javax.swing.GroupLayout(menu);
       menu.setLayout(menuLayout);
       menuLayout.setHorizontalGroup(
           menuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, menuLayout.createSequentialGroup()
               .addContainerGap()
               .addGroup(menuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                   .addComponent(inserir_aviao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                   .addGroup(menuLayout.createSequentialGroup()
                       .addGroup(menuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                           .addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                           .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                       .addGroup(menuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                           .addGroup(menuLayout.createSequentialGroup()
                               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                               .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE))
                           .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, menuLayout.createSequentialGroup()
                               .addGap(4, 4, 4)
                               .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)))))
               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 92, Short.MAX_VALUE)
               .addGroup(menuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                   .addComponent(elimina, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                   .addComponent(listamenu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                   .addComponent(altera, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
               .addGap(32, 32, 32))
       );
       menuLayout.setVerticalGroup(
           menuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(menuLayout.createSequentialGroup()
               .addContainerGap()
               .addGroup(menuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                   .addGroup(menuLayout.createSequentialGroup()
                       .addGroup(menuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                           .addComponent(jButton1)
                           .addComponent(jButton4))
                       .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                       .addGroup(menuLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                           .addComponent(jButton6)
                           .addComponent(jButton5))
                       .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                       .addComponent(inserir_aviao, javax.swing.GroupLayout.PREFERRED_SIZE, 276, javax.swing.GroupLayout.PREFERRED_SIZE))
                   .addGroup(menuLayout.createSequentialGroup()
                       .addComponent(listamenu, javax.swing.GroupLayout.PREFERRED_SIZE, 189, javax.swing.GroupLayout.PREFERRED_SIZE)
                       .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                       .addComponent(altera, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
               .addGap(30, 30, 30)
               .addComponent(elimina, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addContainerGap(45, Short.MAX_VALUE))
       );

       jLabel5.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
       jLabel5.setText("Gestão de Rotas");

       jLabel6.setText("Gestão de Rotas > Avião");

       Aviaos.setBackground(new java.awt.Color(102, 102, 102));
       Aviaos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/bt_aviao.png"))); // NOI18N
       Aviaos.setText("Avião");
       Aviaos.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               AviaosActionPerformed(evt);
           }
       });

       Piloto1.setText("Piloto");
       Piloto1.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               Piloto1ActionPerformed(evt);
           }
       });

       copiloto1.setText("Co-Pioloto");

       voo1.setText("Voo");

       autorizacoes1.setText("Autorizações");

       jButton9.setText("Administração");
       jButton9.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               jButton9ActionPerformed(evt);
           }
       });

       jButton7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/sair.png"))); // NOI18N
       jButton7.setText("Sair");
       jButton7.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               jButton7ActionPerformed(evt);
           }
       });

       javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
       jPanel2.setLayout(jPanel2Layout);
       jPanel2Layout.setHorizontalGroup(
           jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(jPanel2Layout.createSequentialGroup()
               .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                   .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                   .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                       .addComponent(Aviaos, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                       .addComponent(Piloto1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                       .addComponent(copiloto1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                       .addComponent(voo1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                       .addComponent(jButton9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                       .addComponent(autorizacoes1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
               .addGap(0, 123, Short.MAX_VALUE))
       );
       jPanel2Layout.setVerticalGroup(
           jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(jPanel2Layout.createSequentialGroup()
               .addComponent(Aviaos)
               .addGap(18, 18, 18)
               .addComponent(Piloto1, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
               .addComponent(copiloto1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
               .addComponent(voo1, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
               .addComponent(autorizacoes1, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
               .addComponent(jButton9, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addGap(18, 18, 18)
               .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addContainerGap(57, Short.MAX_VALUE))
       );

       javax.swing.GroupLayout pesquisaLayout = new javax.swing.GroupLayout(pesquisa);
       pesquisa.setLayout(pesquisaLayout);
       pesquisaLayout.setHorizontalGroup(
           pesquisaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(pesquisaLayout.createSequentialGroup()
               .addContainerGap()
               .addGroup(pesquisaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                   .addGroup(pesquisaLayout.createSequentialGroup()
                       .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                       .addGap(116, 116, 116)
                       .addComponent(menu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                   .addGroup(pesquisaLayout.createSequentialGroup()
                       .addGap(243, 243, 243)
                       .addComponent(jLabel5))
                   .addGroup(pesquisaLayout.createSequentialGroup()
                       .addGap(279, 279, 279)
                       .addComponent(jLabel6)))
               .addContainerGap(494, Short.MAX_VALUE))
       );
       pesquisaLayout.setVerticalGroup(
           pesquisaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(pesquisaLayout.createSequentialGroup()
               .addGroup(pesquisaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                   .addGroup(pesquisaLayout.createSequentialGroup()
                       .addContainerGap()
                       .addComponent(jLabel5)
                       .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                       .addComponent(jLabel6)
                       .addGap(75, 75, 75)
                       .addComponent(menu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                   .addGroup(pesquisaLayout.createSequentialGroup()
                       .addGap(22, 22, 22)
                       .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
               .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
       );

       javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
       this.setLayout(layout);
       layout.setHorizontalGroup(
           layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
               .addContainerGap()
               .addComponent(pesquisa, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
               .addContainerGap())
       );
       layout.setVerticalGroup(
           layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(layout.createSequentialGroup()
               .addContainerGap()
               .addComponent(pesquisa, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
               .addGap(976, 976, 976))
       );
   }// </editor-fold>

   private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
jButton1.setVisible(false);
jButton4.setVisible(false);
jButton5.setVisible(false);
jButton6.setVisible(false);
inserir_aviao.setVisible(true);
menu.setVisible(true);  
Capacidade.setVisible(false);
jLabel10.setVisible(false);
altera.setVisible(false);
jLabel6.setText("Gestão de Rotas > Avião > Inserir");// TODO add your handling code here:
   }                                        

   private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {                                         
listamenu.setVisible(true);
menu.setVisible(true);
jLabel6.setText("Gestão de Rotas > Avião> Listar");
//this.setSize(542, 500);
jButton1.setVisible(false);
jButton4.setVisible(false);
jButton5.setVisible(false);
jButton6.setVisible(false);
altera.setVisible(false);
//pesquisa();

   }                                        

   private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
   try {

           String matricula = Matricula.getText();
           String companhia = Campanhia.getText();
           BigDecimal capacidade = new BigDecimal(Capacidade.getText());
           if((matricula.equals(""))||(companhia.equals("") )/*||(capacidade.equals(""))**/)
{
javax.swing.JOptionPane.showMessageDialog(null, "Tem inserir dados","",javax.swing.JOptionPane.INFORMATION_MESSAGE);    

}else{


   Aviao fi = new Aviao();

           fi.setMatricula(matricula);
           fi.setCompanhia(companhia);
           fi.setCapacidade(capacidade);
           fi.insereAviao();
           javax.swing.JOptionPane.showMessageDialog(null,"REGISTO COM SUCESSO","", javax.swing.JOptionPane.INFORMATION_MESSAGE);  
           menu.setVisible(true);
           inserir_aviao.setVisible(false);
           listamenu.setVisible(false);
           jButton1.setVisible(true);
           jButton4.setVisible(true);
           jButton5.setVisible(true);
           jButton6.setVisible(true);
           this.setSize(542, 500);
           jLabel6.setText("Gestão de Rotas > Avião");           
           }          
       } catch (SQLException ex) {
        javax.swing.JOptionPane.showMessageDialog(null,ex,"ALGO CORREU MAU", javax.swing.JOptionPane.INFORMATION_MESSAGE);  
       }


           // TODO add your handling code here:
   }                                        

   private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                         
Matricula.setText(null);
Campanhia.setText(null);        // TODO add your handling code here:
   }                                        

   private void jButton8MouseClicked(java.awt.event.MouseEvent evt) {                                      
       // TODO add your handling code here:
   }                                     

   private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {                                         
pesquisa_aviao formUsuario = new pesquisa_aviao(null, true); //instancia jdialog dos usuarios  
       abreDialog(formUsuario);       // TODO add your handling code here:
   }                                        

   private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {                                         
jButton1.setVisible(false);
jButton4.setVisible(false);
jButton5.setVisible(false);
jButton6.setVisible(false);
inserir_aviao.setVisible(false);
menu.setVisible(true);  
jLabel10.setVisible(false);
altera.setVisible(true);
jLabel6.setText("Gestão de Rotas > Avião > Alterar");
// pesquisa1();
//       javax.swing.JOptionPane.showMessageDialog(null, "AINDA ESTA EM CONTRUÇÃO", "Tente Novamente", javax.swing.JOptionPane.INFORMATION_MESSAGE);
   }                                        

   private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {                                          
 pesquisa_aviao_elimina formUsuario1 = new pesquisa_aviao_elimina(null, true); //instancia jdialog dos usuarios  
       abreDialog3(formUsuario1);       // TODO add your handling code here:
                   // TODO add your handling code here:
   }                                         

   private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {                                          
   pesquisa_aviao_altera formUsuario2 = new pesquisa_aviao_altera(null, true); //instancia jdialog dos usuarios  
       abreDialog2(formUsuario2);       // TODO add your handling code here:
             // TODO add your handling code here:
   }                                         

   private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {                                          
       // TODO add your handling code here:
   }                                         

   private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {                                          
int indiceLinha = jTable3.getSelectedRow();
        int indiceColuna = 0;
        Object valorCelula = jTable3.getModel().getValueAt(indiceLinha, indiceColuna);
        try {
             Aviao fi = new Aviao();

           fi.Elimina(valorCelula);
           javax.swing.JOptionPane.showMessageDialog(null,"Aviao foi apagado com sucesso","", javax.swing.JOptionPane.INFORMATION_MESSAGE);  

       } catch (SQLException ex) {
        javax.swing.JOptionPane.showMessageDialog(null,ex,"ALGO CORREU MAU", javax.swing.JOptionPane.INFORMATION_MESSAGE);  
       }// TODO add your handling code here:
       // TODO add your handling code here:
   }                                         

   private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {
       new Login().setVisible(true);
       this.repaint();       // TODO add your handling code here:
   }

   private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {
       /*
        * Piloto panelC = new Piloto(this, this.previousPanel, this.dbo);
        * menu.add(panelC); repaint(); panelC.setVisible(true); // TODO add
        * your handling code here:
        *
        */
   }

   private void Piloto1ActionPerformed(java.awt.event.ActionEvent evt) {
       /*
        * final JPanel p2 = new JPanel(); p2.setVisible(true); p2.add(p2);
        * p2.validate(); p2.repaint();
        *
        */
   }

   private void AviaosActionPerformed(java.awt.event.ActionEvent evt) {
       menu.setVisible(true);
       inserir_aviao.setVisible(false);
       listamenu.setVisible(false);
       jButton1.setVisible(true);
       jButton4.setVisible(true);
       jButton5.setVisible(true);
       jButton6.setVisible(true);
       altera.setVisible(false);
this.setSize(542, 500);
       jLabel6.setText("Gestão de Rotas > Avião");
// TODO add your handling code here:
   }

public void abreDialog(pesquisa_aviao dialog){  
       dialog.setResizable(false);  
       dialog.setLocationRelativeTo(dialog);  
       dialog.setVisible(true);  

}
public void abreDialog2(pesquisa_aviao_altera dialog){  
       dialog.setResizable(false);  
       dialog.setLocationRelativeTo(dialog);  
       dialog.setVisible(true);  

} 
public void abreDialog3(pesquisa_aviao_elimina dialog){  
       dialog.setResizable(false);  
       dialog.setLocationRelativeTo(dialog);  
       dialog.setVisible(true);  

} 
/*
public void pesquisa() {
       DefaultTableModel model1 = (javax.swing.table.DefaultTableModel) jTable1.getModel();

       try {
           List<Aviao> aviao = Aviao.aviao();


           Iterator<Aviao> avioespro = aviao.iterator();

           while (avioespro.hasNext()) {
               Aviao p = avioespro.next();

               model1.addRow(new Object[]{p.getIdAviao(),p.getMatricula(), p.getCompanhia()});
           }

       } catch (java.sql.SQLException ex) {

       }

   }
public void pesquisa1() {
       DefaultTableModel model1 = (javax.swing.table.DefaultTableModel) jTable2.getModel();

       try {
           List<Aviao> aviao = Aviao.aviao();


           Iterator<Aviao> avioespro = aviao.iterator();

           while (avioespro.hasNext()) {
               Aviao p = avioespro.next();

               model1.addRow(new Object[]{p.getIdAviao(),p.getMatricula(), p.getCompanhia()});
           }

       } catch (java.sql.SQLException ex) {

       }

   }
   * 
   */

   // Variables declaration - do not modify
   private javax.swing.JButton Administração;
   private javax.swing.JButton Aviao;
   private javax.swing.JButton Aviaos;
   private javax.swing.JTextField Campanhia;
   private javax.swing.JTextField Capacidade;
   private javax.swing.JFormattedTextField Matricula;
   private javax.swing.JTextField Pesquisa;
   private javax.swing.JTextField Pesquisa_altera;
   private javax.swing.JTextField Pesquisa_elimina;
   private javax.swing.JButton Piloto1;
   private javax.swing.JPanel altera;
   private javax.swing.JButton autorizacoes;
   private javax.swing.JButton autorizacoes1;
   private javax.swing.JButton copiloto;
   private javax.swing.JButton copiloto1;
   private javax.swing.JPanel elimina;
   private javax.swing.JPanel inserir_aviao;
   private javax.swing.JButton jButton1;
   private javax.swing.JButton jButton10;
   private javax.swing.JButton jButton11;
   private javax.swing.JButton jButton12;
   private javax.swing.JButton jButton13;
   private javax.swing.JButton jButton14;
   private javax.swing.JButton jButton2;
   private javax.swing.JButton jButton3;
   private javax.swing.JButton jButton4;
   private javax.swing.JButton jButton5;
   private javax.swing.JButton jButton6;
   private javax.swing.JButton jButton7;
   private javax.swing.JButton jButton8;
   private javax.swing.JButton jButton9;
   private javax.swing.JLabel jLabel1;
   private javax.swing.JLabel jLabel10;
   private javax.swing.JLabel jLabel2;
   private javax.swing.JLabel jLabel3;
   private javax.swing.JLabel jLabel5;
   private javax.swing.JLabel jLabel6;
   private javax.swing.JLabel jLabel8;
   private javax.swing.JLabel jLabel9;
   private javax.swing.JPanel jPanel1;
   private javax.swing.JPanel jPanel2;
   private javax.swing.JScrollPane jScrollPane1;
   private javax.swing.JScrollPane jScrollPane2;
   private javax.swing.JScrollPane jScrollPane3;
   private javax.swing.JTable jTable1;
   private javax.swing.JTable jTable2;
   private javax.swing.JTable jTable3;
   private javax.swing.JPanel listamenu;
   private javax.swing.JPanel menu;
   private javax.swing.JPanel pesquisa;
   private javax.swing.JButton piloto;
   private javax.swing.JLabel relogio;
   private javax.swing.JButton voo;
   private javax.swing.JButton voo1;
   // End of variables declaration
}

no menuprincipal.java

package Gestao_Rotas;

import HelperDB.DBAccessObj;
import classes.relogio;
import javax.swing.JPanel;




/**
*
* @author Alves
*/
public class MENUPRINCIPAL extends javax.swing.JFrame {
private DBAccessObj dbo;
   private JPanel visiblePanel=null;

    //private JPanel visiblePanel2=null;

 /*
    * Creates new form MENUPRINCIPAL
    */
   public MENUPRINCIPAL(String nome,String nivel) {
      relogio r = new relogio();
        this.getContentPane().add(r, relogio);

        initComponents();
       dbo= new DBAccessObj();
       setIconImage(getToolkit().getImage("src\\imagens\\icon_aplicacao.png")); //Coloca o ícone na aplicação

       this.visiblePanel =this.jPanel1;
       this.jLabel3.setText("Nome do Utilizador: "+nome+"");
       this.setResizable(false);
       this.jLabel4.setText("Seja Bem Vindo ao Software de Gestao de Rotas");
      // this.visiblePanel2=this.jPanel1;


    Aviao.setVisible(false);
           piloto.setVisible(false);
           copiloto.setVisible(false);
           voo.setVisible(false);
           autorizacoes.setVisible(false);
           jButton7.setVisible(false);
            Administração.setVisible(false);


     if(nome.equals("Administrador") )
       {
        Aviao.setVisible(true);
           piloto.setVisible(true);
           copiloto.setVisible(true);
           voo.setVisible(true);
           autorizacoes.setVisible(true);
           jButton7.setVisible(true);
           Administração.setVisible(true);


       } else{
           Aviao.setVisible(false);
           piloto.setVisible(false);
           copiloto.setVisible(false);
           voo.setVisible(true);
           autorizacoes.setVisible(true);
           this.autorizacoes.setSize(1,1);
           jButton7.setVisible(true);
           Administração.setVisible(false);




       }

   }


   /**
    * 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() {

       jPanel1 = new javax.swing.JPanel();
       Aviao = new javax.swing.JButton();
       piloto = new javax.swing.JButton();
       copiloto = new javax.swing.JButton();
       voo = new javax.swing.JButton();
       autorizacoes = new javax.swing.JButton();
       jButton7 = new javax.swing.JButton();
       relogio = new javax.swing.JLabel();
       Administração = new javax.swing.JButton();
       benvindo = new javax.swing.JPanel();
       jLabel3 = new javax.swing.JLabel();
       jLabel4 = new javax.swing.JLabel();
       jPanel2 = new javax.swing.JPanel();
       jLabel2 = new javax.swing.JLabel();
       jLabel1 = new javax.swing.JLabel();

       setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
       setTitle("Gestão de Rotas > Menu Principal");
       setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

       jPanel1.setBorder(javax.swing.BorderFactory.createCompoundBorder(null, javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))));

       Aviao.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
       Aviao.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/aviao.png"))); // NOI18N
       Aviao.setText("Avião");
       Aviao.setPreferredSize(new java.awt.Dimension(99, 43));
       Aviao.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               AviaoActionPerformed(evt);
           }
       });

       piloto.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
       piloto.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/piloto.PNG"))); // NOI18N
       piloto.setText("Piloto");
       piloto.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               pilotoActionPerformed(evt);
           }
       });

       copiloto.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
       copiloto.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/co_piloto.png"))); // NOI18N
       copiloto.setText("Co-Pioloto");
       copiloto.setPreferredSize(new java.awt.Dimension(99, 43));

       voo.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
       voo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/voo.png"))); // NOI18N
       voo.setText("Voo");
       voo.setPreferredSize(new java.awt.Dimension(99, 43));
       voo.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               vooActionPerformed(evt);
           }
       });

       autorizacoes.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
       autorizacoes.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/autorizacao.png"))); // NOI18N
       autorizacoes.setText("Autorizações");
       autorizacoes.setPreferredSize(new java.awt.Dimension(99, 43));

       jButton7.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
       jButton7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/sair.png"))); // NOI18N
       jButton7.setText("Terminar Sessão");
       jButton7.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               jButton7ActionPerformed(evt);
           }
       });

       relogio.setText("Relogio");

       Administração.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
       Administração.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/Administracao.png"))); // NOI18N
       Administração.setText("Administração");
       Administração.setPreferredSize(new java.awt.Dimension(99, 43));
       Administração.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               AdministraçãoActionPerformed(evt);
           }
       });

       javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
       jPanel1.setLayout(jPanel1Layout);
       jPanel1Layout.setHorizontalGroup(
           jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(jPanel1Layout.createSequentialGroup()
               .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                   .addGroup(jPanel1Layout.createSequentialGroup()
                       .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                           .addGroup(jPanel1Layout.createSequentialGroup()
                               .addContainerGap()
                               .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                   .addComponent(autorizacoes, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE)
                                   .addComponent(voo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                   .addComponent(copiloto, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                   .addComponent(piloto, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                   .addComponent(Aviao, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                   .addComponent(Administração, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                           .addGroup(jPanel1Layout.createSequentialGroup()
                               .addGap(24, 24, 24)
                               .addComponent(relogio, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)))
                       .addGap(0, 0, Short.MAX_VALUE))
                   .addGroup(jPanel1Layout.createSequentialGroup()
                       .addContainerGap()
                       .addComponent(jButton7, javax.swing.GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE)))
               .addContainerGap())
       );
       jPanel1Layout.setVerticalGroup(
           jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(jPanel1Layout.createSequentialGroup()
               .addContainerGap()
               .addComponent(Aviao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addGap(18, 18, 18)
               .addComponent(piloto, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addGap(18, 18, 18)
               .addComponent(copiloto, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
               .addComponent(voo, javax.swing.GroupLayout.DEFAULT_SIZE, 33, Short.MAX_VALUE)
               .addGap(16, 16, 16)
               .addComponent(autorizacoes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addGap(42, 42, 42)
               .addComponent(Administração, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addGap(18, 18, 18)
               .addComponent(jButton7)
               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
               .addComponent(relogio)
               .addContainerGap())
       );

       jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
       jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
       jLabel3.setText("jLabel3");

       jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
       jLabel4.setText("jLabel4");

       javax.swing.GroupLayout benvindoLayout = new javax.swing.GroupLayout(benvindo);
       benvindo.setLayout(benvindoLayout);
       benvindoLayout.setHorizontalGroup(
           benvindoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(benvindoLayout.createSequentialGroup()
               .addContainerGap()
               .addGroup(benvindoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                   .addComponent(jLabel4)
                   .addComponent(jLabel3))
               .addContainerGap(209, Short.MAX_VALUE))
       );
       benvindoLayout.setVerticalGroup(
           benvindoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(benvindoLayout.createSequentialGroup()
               .addGap(23, 23, 23)
               .addComponent(jLabel3)
               .addGap(18, 18, 18)
               .addComponent(jLabel4)
               .addContainerGap(76, Short.MAX_VALUE))
       );

       jPanel2.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createCompoundBorder(), javax.swing.BorderFactory.createCompoundBorder()));
       jPanel2.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
       jPanel2.setEnabled(false);

       jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
       jLabel2.setText("Gestão de Rotas");

       jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
       jLabel1.setText("Gestão de Rotas");

       javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
       jPanel2.setLayout(jPanel2Layout);
       jPanel2Layout.setHorizontalGroup(
           jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(jPanel2Layout.createSequentialGroup()
               .addGap(108, 108, 108)
               .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                   .addComponent(jLabel1)
                   .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                       .addComponent(jLabel2)
                       .addGap(45, 45, 45)))
               .addContainerGap(108, Short.MAX_VALUE))
       );
       jPanel2Layout.setVerticalGroup(
           jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(jPanel2Layout.createSequentialGroup()
               .addComponent(jLabel1)
               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
               .addComponent(jLabel2)
               .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
       );

       javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
       getContentPane().setLayout(layout);
       layout.setHorizontalGroup(
           layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(layout.createSequentialGroup()
               .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                   .addGroup(layout.createSequentialGroup()
                       .addGap(57, 57, 57)
                       .addComponent(benvindo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                   .addGroup(layout.createSequentialGroup()
                       .addGap(18, 18, 18)
                       .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
               .addContainerGap(12, Short.MAX_VALUE))
       );
       layout.setVerticalGroup(
           layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(layout.createSequentialGroup()
               .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addGap(91, 91, 91)
               .addComponent(benvindo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addGap(0, 0, Short.MAX_VALUE))
           .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
       );

       java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
       setBounds((screenSize.width-629)/2, (screenSize.height-471)/2, 629, 471);
   }// </editor-fold>                        

   private void AviaoActionPerformed(java.awt.event.ActionEvent evt) {                                      

        aviao2 listbooksP = new aviao2(this, this.jPanel1, this.dbo);

       //this.switchPanels(this.visiblePanel, listbooksP);
       this.visiblePanel.setVisible(false);
       this.visiblePanel = listbooksP;
       listbooksP.setVisible(true);
       this.setContentPane(listbooksP);
       this.repaint();

        // TODO add your handling code here:
   }                                     


   private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {                                         
       new Login().setVisible(true);
              this.dispose();// TODO add your handling code here:
   }                                        

   private void AdministraçãoActionPerformed(java.awt.event.ActionEvent evt) {                                              
Administracao1 administrador = new Administracao1 (null, true); //instancia jdialog dos usuarios  
       abreDialog(administrador);
    // TODO add your handling code here:
   }                                             

   private void pilotoActionPerformed(java.awt.event.ActionEvent evt) {                                       
/*
 Piloto ola = new Piloto(this, this.jPanel1, this.dbo);
       this.visiblePanel2.setVisible(false);
       this.visiblePanel2 = ola;
       ola.setVisible(true);
       this.setContentPane(ola);
       this.repaint(); // TODO add your handling code here:*/

   }                                      

   private void vooActionPerformed(java.awt.event.ActionEvent evt) {                                    
       // TODO add your handling code here:
   }                                   
public void abreDialog(Administracao1 dialog){  
       dialog.setResizable(false);  
       dialog.setLocationRelativeTo(dialog);  
       dialog.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() {

           @Override
           public void run() {
            // new MENUPRINCIPAL().setVisible(true);
           }
       });
   }
   // Variables declaration - do not modify                     
   private javax.swing.JButton Administração;
   private javax.swing.JButton Aviao;
   private javax.swing.JButton autorizacoes;
   private javax.swing.JPanel benvindo;
   private javax.swing.JButton copiloto;
   private javax.swing.JButton jButton7;
   private javax.swing.JLabel jLabel1;
   private javax.swing.JLabel jLabel2;
   private javax.swing.JLabel jLabel3;
   private javax.swing.JLabel jLabel4;
   private javax.swing.JPanel jPanel1;
   private javax.swing.JPanel jPanel2;
   private javax.swing.JButton piloto;
   private javax.swing.JLabel relogio;
   private javax.swing.JButton voo;
   // End of variables declaration                   
}

no qual da-me os seguintes erros

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(ImageIcon.java:205)
at Gestao_Rotas.aviao2.initComponents(aviao2.java:461)
at Gestao_Rotas.aviao2.<init>(aviao2.java:29)
at Gestao_Rotas.MENUPRINCIPAL.AviaoActionPerformed(MENUPRINCIPAL.java:321)
at Gestao_Rotas.MENUPRINCIPAL.access$000(MENUPRINCIPAL.java:29)
at Gestao_Rotas.MENUPRINCIPAL$1.actionPerformed(MENUPRINCIPAL.java:128)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6505)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6270)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2713)
at java.awt.Component.dispatchEvent(Component.java:4687)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707)
at java.awt.EventQueue.access$000(EventQueue.java:101)
at java.awt.EventQueue$3.run(EventQueue.java:666)
at java.awt.EventQueue$3.run(EventQueue.java:664)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:680)
at java.awt.EventQueue$4.run(EventQueue.java:678)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:677)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.