Ilegal start expression

1 resposta
L

Oi..boa noite!
Para a faculdade preciso fazer um programa que tenha 2 CRUDS....estou tentando repetir a receita para acertar a pesquisa ordem de serviço mas dá um erro...podem tentaR me ajudar a arrumar?

package view;

import java.util.ArrayList;
import java.util.List;
import model.ClienteBean;
import model.ClienteDao;
import model.ItemOrdemServicoBean;
import model.OrdemServicoBean;
import model.OrdemServicoDao;

/**
 *
 * @author Avell 5BLBN
 */
public class PesquisaOrdemServicos extends javax.swing.JFrame {
    private List<OrdemServicoBean> listaordem;
    private int linhaselecionada =-1;
    PesquisaOrdemServicosTableModel  modelOrdemServicos;
    /** Creates new form PesquisaCliente */
//    public PesquisaOrdemServicos() {
//        this.listaordem = new ArrayList<OrdemServicoBean>();
//        initComponents();
//        gerarTableModelPesquisaOrdemServicos();
  //  }

    private PesquisaOrdemServicos(List<OrdemServicoBean> listaordem) {//sei lá
        //throw new UnsupportedOperationException("Not yet implemented");
         public PesquisaOrdemServicos() {
        this.listaordem = new ArrayList<OrdemServicoBean>();
        initComponents();
        gerarTableModelPesquisaOrdemServicos();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        cdCampo = new javax.swing.JComboBox();
        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        edValor = new javax.swing.JTextField();
        btok = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        pesquisaOrdemServicojTable = new javax.swing.JTable();
        btvoltar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel1.setText("Pesquisar Por:");

        cdCampo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Código", "Cliente", "Data" }));
        cdCampo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cdCampoActionPerformed(evt);
            }
        });

        jPanel1.setBackground(new java.awt.Color(204, 204, 255));
        jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));

        jLabel2.setBackground(new java.awt.Color(255, 255, 255));
        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel2.setText("Pesquisa Ordens de Serviço");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(141, 141, 141)
                .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 210, Short.MAX_VALUE)
                .addGap(167, 167, 167))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 25, Short.MAX_VALUE)
                .addContainerGap())
        );

        edValor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                edValorActionPerformed(evt);
            }
        });

        btok.setText("OK");
        btok.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btokActionPerformed(evt);
            }
        });

        pesquisaOrdemServicojTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        pesquisaOrdemServicojTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                pesquisaOrdemServicojTableMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(pesquisaOrdemServicojTable);

        btvoltar.setText("Voltar");
        btvoltar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btvoltarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel1)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(cdCampo, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(edValor, javax.swing.GroupLayout.PREFERRED_SIZE, 344, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(btok, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 724, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addContainerGap(683, Short.MAX_VALUE)
                        .addComponent(btvoltar)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cdCampo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(edValor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btok))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 367, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btvoltar)
                .addContainerGap(13, Short.MAX_VALUE))
        );

        edValor.getAccessibleContext().setAccessibleName("edvalor");

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

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

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

private void btokActionPerformed(java.awt.event.ActionEvent evt) {                                     
    consultarOrdemServico(cdCampo.getSelectedItem().toString());
}                                    

private void pesquisaOrdemServicojTableMouseClicked(java.awt.event.MouseEvent evt) {                                                        
// TODO add your handling code here:
    linhaselecionada = pesquisaOrdemServicojTable.getSelectedRow();
    if(linhaselecionada != -1){
        String codigoStr = pesquisaOrdemServicojTable.getValueAt(linhaselecionada,0).toString();
        String nomeStr =   pesquisaOrdemServicojTable.getValueAt(linhaselecionada,1).toString();
        ordensDeServiços telaOrdem = new ordensDeServiços();
        telaOrdem.setCodigo(codigoStr);
        telaOrdem.setNomeCliente(nomeStr);
        telaOrdem.setVisible(true);
        dispose();
    }   
}                                                       

private void btvoltarActionPerformed(java.awt.event.ActionEvent evt) {                                         
// TODO add your handling code here:
    new ordensDeServiços().setVisible(true);
}                                        

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new PesquisaOrdemServicos().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify                     
    private javax.swing.JButton btok;
    private javax.swing.JButton btvoltar;
    private javax.swing.JComboBox cdCampo;
    private javax.swing.JTextField edValor;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable pesquisaOrdemServicojTable;
    // End of variables declaration                   
    private void consultarOrdemServico(String tipoConsulta) {
        OrdemServicoDao ordemservicoDao = new OrdemServicoDao();
        String comando = null;
        if (tipoConsulta.equalsIgnoreCase("Código")) {
            comando = "Select * from cad_os where cod=" + edValor.getText();
        }else if (tipoConsulta.equalsIgnoreCase("Nome")){
            comando = "Select * from cad_os  where  nome like  '" + edValor.getText() + "%'";
        }else if (tipoConsulta.equalsIgnoreCase("CPF")){
            comando = "Select * from cad_os where cpfcnpj='" + edValor.getText() + "'";
        }
        listaordem = ordemservicoDao.selecionar(comando);
        gerarTableModelPesquisaOrdemServicos();
    }
    
    public void gerarTableModelPesquisaOrdemServicos(){//arrumar esse ---alterar dados
        modelOrdemServicos = new PesquisaOrdemServicos(listaordem);
        pesquisaOrdemServicojTable.setModel(modelOrdemServicos);
        pesquisaOrdemServicojTable.getColumnModel().getColumn(0).setPreferredWidth(10);
        pesquisaOrdemServicojTable.getColumnModel().getColumn(1).setPreferredWidth(200);
        pesquisaOrdemServicojTable.getColumnModel().getColumn(2).setPreferredWidth(20);
        pesquisaOrdemServicojTable.getColumnModel().getColumn(3).setPreferredWidth(20);
        pesquisaOrdemServicojTable.getColumnModel().getColumn(4).setPreferredWidth(50);
        pesquisaOrdemServicojTable.repaint();
    }

}

1 Resposta

luxu

kd o erro(printstacktrace)?

Criado 14 de novembro de 2011
Ultima resposta 15 de nov. de 2011
Respostas 1
Participantes 2