Ir para conteúdo

Arquivado

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

Pedroalves

[Resolvido] pesquisa dinamica

Recommended Posts

estou a tentar por as minhas pesquisas dinamicas mas não sei como fazer

alguem me pode ajudar

e como valido os campos por tipos

tipo na quantidades so aceitarem numeros e no mail ter que ter o @

Compartilhar este post


Link para o post
Compartilhar em outros sites

Olá boa tarde!

Você pode criar metodos na sua propria class para verificar os tipos.Por exemplo verificar se o e-mail é valido

 

public void valida_email(String email){
 if (email.indexOF("@")< 0){
  //erro se o e-mail não possuir o @;
}
 else{
   //condição aceita... 
     }
}

e assim por diante.. (Me corrijam se estiver enganado :D)

 

quanto a pesquisa você precisa especificar um pouquinho mais hehe..

Espero ter ajudado.

abraço

Compartilhar este post


Link para o post
Compartilhar em outros sites

Não sei se é isso que você quer + ... para verificar se é String ou integer, pode-se usar

um bloco try

 try {
 if (Integer.parseInt(teste) >= 0 || Integer.parseInt(teste) < 10) {
 //minha lógica
     }
     } catch (NumberFormatException e) {
       //System.out.println(e.getMessage());                    
     }

Nesse caso ele verifica se oque há na palavra é um numero entre 1 e 10.

abraço

Compartilhar este post


Link para o post
Compartilhar em outros sites

por acaso não sabe como fazer um pesquisa dinamica

tipo eu quero pesquisar um nome maria

eu degito o M e aparece na jtable todos o nome começados por m

 

eu quero por a aceitar no jtexte so letras

e noutro so numeros

Compartilhar este post


Link para o post
Compartilhar em outros sites

Para a pesquisa, você deve ter um evento KeyListener no seu textField. Assim, cada vez que o usuário digitar algo, você faz a pesquisa com o valor do textField.

 

Para fazer a formatação que você quer, pode-se usar JFormattedTextField.

Compartilhar este post


Link para o post
Compartilhar em outros sites

e como faço isso

segue-se o meu codigo não estou a conseguir fazer

package Gestao_Rotas;

import java.sql.ResultSet;
import java.sql.SQLException;
import HelperDB.DBAccessObj;
import classes.Aviao;
import java.util.Iterator;
import java.util.List;
import javax.swing.table.DefaultTableModel;
import Gestao_Rotas.aviao2;

/**
*
* @author Alves
*/
public class pesquisa_aviao extends javax.swing.JDialog {
private DBAccessObj dbo;
   /**
    * Creates new form pesquisa_aviao
    */
   public pesquisa_aviao(java.awt.Frame parent, boolean modal) {
       super(parent, modal);
       initComponents();
       this.pesquisa.setText(null);
       this.dbo = dbo;
       pesquisa(dbo);
       //
      //d your handling code here:
   }

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

       jButton10 = new javax.swing.JButton();
       jButton9 = new javax.swing.JButton();
       jScrollPane2 = new javax.swing.JScrollPane();
       javiao = new javax.swing.JTable();
       jLabel4 = new javax.swing.JLabel();
       jLabel3 = new javax.swing.JLabel();
       pesquisa = new javax.swing.JTextField();

       setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

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

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

       javiao.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(javiao);

       jLabel4.setText("Procurar Aviao");

       jLabel3.setText("Matricula");

       javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
       getContentPane().setLayout(layout);
       layout.setHorizontalGroup(
           layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
           .addGroup(layout.createSequentialGroup()
               .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                   .addGroup(layout.createSequentialGroup()
                       .addGap(157, 157, 157)
                       .addComponent(jLabel4)
                       .addGap(0, 0, Short.MAX_VALUE))
                   .addGroup(layout.createSequentialGroup()
                       .addContainerGap()
                       .addComponent(jLabel3)
                       .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                       .addComponent(pesquisa)
                       .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                       .addComponent(jButton9, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)))
               .addContainerGap())
           .addGroup(layout.createSequentialGroup()
               .addComponent(jButton10, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addGap(0, 0, Short.MAX_VALUE))
       );
       layout.setVerticalGroup(
           layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(layout.createSequentialGroup()
               .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
               .addComponent(jLabel4)
               .addGap(6, 6, 6)
               .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                   .addComponent(jLabel3)
                   .addComponent(jButton9)
                   .addComponent(pesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
               .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 224, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
               .addComponent(jButton10)
               .addGap(52, 52, 52))
       );

       pack();
   }// </editor-fold>

   private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {                                         
 DefaultTableModel model1 = (javax.swing.table.DefaultTableModel) javiao.getModel();
      String Matricula =pesquisa.getText(); 
       try {
           List<Aviao> aviao = Aviao.getaviao(Matricula);
           Iterator<Aviao> avioespro = aviao.iterator();
           if(Matricula.equals(Aviao.getaviao(Matricula))){
            while (avioespro.hasNext()) {
               Aviao p = avioespro.next();

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

           }
           else
           javiao.setToolTipText("NAO EXISTE DADOS");

       } catch (java.sql.SQLException ex) {

       }
   }                                        

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

           fi.insereAviao_TEMP(valorCelula);
           javax.swing.JOptionPane.showMessageDialog(null,"REGISTO 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:
   }                                         
 public void oes(){
 DefaultTableModel model1 = (javax.swing.table.DefaultTableModel) javiao.getModel();
      String Matricula =pesquisa.getText(); 
      try {
           List<Aviao> aviao = Aviao.getaviao(Matricula);

           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 pesquisa(DBAccessObj dbo) {
       DefaultTableModel model1 = (javax.swing.table.DefaultTableModel) javiao.getModel();

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

           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) {

       }

   }
   /**
    * @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(pesquisa_aviao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
       } catch (InstantiationException ex) {
           java.util.logging.Logger.getLogger(pesquisa_aviao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
       } catch (IllegalAccessException ex) {
           java.util.logging.Logger.getLogger(pesquisa_aviao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
       } catch (javax.swing.UnsupportedLookAndFeelException ex) {
           java.util.logging.Logger.getLogger(pesquisa_aviao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
       }
       //</editor-fold>

       /*
        * Create and display the dialog
        */
       java.awt.EventQueue.invokeLater(new Runnable() {

           public void run() {
               pesquisa_aviao dialog = new pesquisa_aviao(new javax.swing.JFrame(), true);
               dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                   @Override
                   public void windowClosing(java.awt.event.WindowEvent e) {
                       System.exit(0);
                   }
               });
               dialog.setVisible(true);
           }
       });
   }
   // Variables declaration - do not modify
   private javax.swing.JButton jButton10;
   private javax.swing.JButton jButton9;
   private javax.swing.JLabel jLabel3;
   private javax.swing.JLabel jLabel4;
   private javax.swing.JScrollPane jScrollPane2;
   private javax.swing.JTable javiao;
   private javax.swing.JTextField pesquisa;
   // End of variables declaration
}

Compartilhar este post


Link para o post
Compartilhar em outros sites
e como faço isso

KeyEvent http://docs.oracle.com/javase/tutorial/uiswing/events/keylistener.html

JFormattedTextField http://docs.oracle.com/javase/tutorial/uiswing/components/formattedtextfield.html

 

Esses dois links tem tudo o que você precisa. Inclusive exemplo de código.

Compartilhar este post


Link para o post
Compartilhar em outros sites

não estou a conseguir segue-se o codigo

package Gestao_Rotas;

import java.sql.ResultSet;
import java.sql.SQLException;
import HelperDB.DBAccessObj;
import classes.Aviao;
import java.util.Iterator;
import java.util.List;
import javax.swing.table.DefaultTableModel;
import Gestao_Rotas.aviao2;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.event.*;
import javax.swing.*;
/**
*
* @author Alves
*/
public class pesquisa_aviao extends javax.swing.JDialog {
private DBAccessObj dbo;

   /**
    * Creates new form pesquisa_aviao
    */
   public pesquisa_aviao(java.awt.Frame parent, boolean modal) {
       super(parent, modal);
       initComponents();
       this.pesquisa.setText(null);
       this.dbo = dbo;
       pesquisa(dbo);

       //
      //d your handling code here:
   }

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

       jButton10 = new javax.swing.JButton();
       jButton9 = new javax.swing.JButton();
       jScrollPane2 = new javax.swing.JScrollPane();
       javiao = new javax.swing.JTable();
       jLabel4 = new javax.swing.JLabel();
       jLabel3 = new javax.swing.JLabel();
       pesquisa = new javax.swing.JTextField();

       setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

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

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

       javiao.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(javiao);

       jLabel4.setText("Procurar Aviao");

       jLabel3.setText("Matricula");

       javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
       getContentPane().setLayout(layout);
       layout.setHorizontalGroup(
           layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
           .addGroup(layout.createSequentialGroup()
               .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                   .addGroup(layout.createSequentialGroup()
                       .addGap(157, 157, 157)
                       .addComponent(jLabel4)
                       .addGap(0, 0, Short.MAX_VALUE))
                   .addGroup(layout.createSequentialGroup()
                       .addContainerGap()
                       .addComponent(jLabel3)
                       .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                       .addComponent(pesquisa)
                       .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                       .addComponent(jButton9, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)))
               .addContainerGap())
           .addGroup(layout.createSequentialGroup()
               .addComponent(jButton10, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addGap(0, 0, Short.MAX_VALUE))
       );
       layout.setVerticalGroup(
           layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(layout.createSequentialGroup()
               .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
               .addComponent(jLabel4)
               .addGap(6, 6, 6)
               .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                   .addComponent(jLabel3)
                   .addComponent(jButton9)
                   .addComponent(pesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
               .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 224, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
               .addComponent(jButton10)
               .addGap(52, 52, 52))
       );

       pack();
   }// </editor-fold>                        

   private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {                                         
 DefaultTableModel model1 = (javax.swing.table.DefaultTableModel) javiao.getModel();
      String Matricula =pesquisa.getText(); 
       try {
           List<Aviao> aviao = Aviao.getaviao(Matricula);
           Iterator<Aviao> avioespro = aviao.iterator();
           if(Matricula.equals(Aviao.getaviao(Matricula))){
            while (avioespro.hasNext()) {
               Aviao p = avioespro.next();

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

           }
           else
           javiao.setToolTipText("NAO EXISTE DADOS");

       } catch (java.sql.SQLException ex) {

       }
   }                                        

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

           fi.insereAviao_TEMP(valorCelula);
           javax.swing.JOptionPane.showMessageDialog(null,"REGISTO 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:
   }                                         
 public void oes(){
 DefaultTableModel model1 = (javax.swing.table.DefaultTableModel) javiao.getModel();
      String Matricula =pesquisa.getText(); 
      try {
           List<Aviao> aviao = Aviao.getaviao(Matricula);

           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 KeyEventDemo(String Matricula) {
       super(Matricula);
   }


   /** Handle the key typed event from the text field. */
   public void keyTyped(KeyEvent e) {
       displayInfo(e, "KEY TYPED: ");
   }

   /** Handle the key pressed event from the text field. */
   public void keyPressed(KeyEvent e) {
       displayInfo(e, "KEY PRESSED: ");
   }

   /** Handle the key released event from the text field. */
   public void keyReleased(KeyEvent e) {
       displayInfo(e, "KEY RELEASED: ");
   }

   /** Handle the button click. */
   public void actionPerformed(ActionEvent e) {
       //Clear the text components.
       displayArea.setText("");
       typingArea.setText("");

       //Return the focus to the typing area.
       typingArea.requestFocusInWindow();
   }

   /*
    * We have to jump through some hoops to avoid
    * trying to print non-printing characters
    * such as Shift.  (Not only do they not print,
    * but if you put them in a String, the characters
    * afterward won't show up in the text area.)
    */
   private void displayInfo(KeyEvent e, String keyStatus){

       //You should only rely on the key char if the event
       //is a key typed event.
       int id = e.getID();
       String keyString;
       if (id == KeyEvent.KEY_TYPED) {
           char c = e.getKeyChar();
           keyString = "key character = '" + c + "'";
       } else {
           int keyCode = e.getKeyCode();
           keyString = "key code = " + keyCode
                   + " ("
                   + KeyEvent.getKeyText(keyCode)
                   + ")";
       }

       int modifiersEx = e.getModifiersEx();
       String modString = "extended modifiers = " + modifiersEx;
       String tmpString = KeyEvent.getModifiersExText(modifiersEx);
       if (tmpString.length() > 0) {
           modString += " (" + tmpString + ")";
       } else {
           modString += " (no extended modifiers)";
       }

       String actionString = "action key? ";
       if (e.isActionKey()) {
           actionString += "YES";
       } else {
           actionString += "NO";
       }

       String locationString = "key location: ";
       int location = e.getKeyLocation();
       if (location == KeyEvent.KEY_LOCATION_STANDARD) {
           locationString += "standard";
       } else if (location == KeyEvent.KEY_LOCATION_LEFT) {
           locationString += "left";
       } else if (location == KeyEvent.KEY_LOCATION_RIGHT) {
           locationString += "right";
       } else if (location == KeyEvent.KEY_LOCATION_NUMPAD) {
           locationString += "numpad";
       } else { // (location == KeyEvent.KEY_LOCATION_UNKNOWN)
           locationString += "unknown";
       }

       displayArea.append(keyStatus + newline
               + "    " + keyString + newline
               + "    " + modString + newline
               + "    " + actionString + newline
               + "    " + locationString + newline);
       displayArea.setCaretPosition(displayArea.getDocument().getLength());
   }
    public void pesquisa(DBAccessObj dbo) {
       DefaultTableModel model1 = (javax.swing.table.DefaultTableModel) javiao.getModel();

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

           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) {

       }

   }

   /**
    * @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(pesquisa_aviao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
       } catch (InstantiationException ex) {
           java.util.logging.Logger.getLogger(pesquisa_aviao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
       } catch (IllegalAccessException ex) {
           java.util.logging.Logger.getLogger(pesquisa_aviao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
       } catch (javax.swing.UnsupportedLookAndFeelException ex) {
           java.util.logging.Logger.getLogger(pesquisa_aviao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
       }
       //</editor-fold>

       /*
        * Create and display the dialog
        */
       java.awt.EventQueue.invokeLater(new Runnable() {

           public void run() {
               pesquisa_aviao dialog = new pesquisa_aviao(new javax.swing.JFrame(), true);
               dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                   @Override
                   public void windowClosing(java.awt.event.WindowEvent e) {
                       System.exit(0);
                   }
               });
               dialog.setVisible(true);
           }
       });
   }
   // Variables declaration - do not modify                     
   private javax.swing.JButton jButton10;
   private javax.swing.JButton jButton9;
   private javax.swing.JLabel jLabel3;
   private javax.swing.JLabel jLabel4;
   private javax.swing.JScrollPane jScrollPane2;
   private javax.swing.JTable javiao;
   private javax.swing.JTextField pesquisa;
   // End of variables declaration                   
}

Compartilhar este post


Link para o post
Compartilhar em outros sites
não estou a conseguir segue-se o codigo

Como você quer que funcione se você não adicionou um listener keyEvent ao seu textField ou textArea?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Retirado do link que te passei. Primeira coisa é escrever uma classe (pode ser anônima) que implemente a interface KeyListener. Por exemplo:

public class MinhaClasse {

 // Todo meu código bizarro aqui...

 private void initComponents() {
   this.pesquisa.addKeyListener(new KeyEventPesquisa());
 }

 private class KeyEventPesquisa implements KeyListener {
   public void keyTyped(KeyEvent e) {
     displayInfo(e, "KEY TYPED: ");
   }

   public void keyPressed(KeyEvent e) {
     displayInfo(e, "KEY PRESSED: ");
   }

   public void keyReleased(KeyEvent e) {
     displayInfo(e, "KEY RELEASED: ");
   }

   private void displayInfo(KeyEvent e) {
     // Aqui você faz a pesquisa no banco e atualiza o modelo do JTable.
   }
 }
}

Compartilhar este post


Link para o post
Compartilhar em outros sites

ja agora como passo um valor de um jtable que esta num jdialog para um jtable que esta num jpanel

se calhar fica mais facil criar uma tabela temporaria

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.