[Erro] Formulario

2 respostas
victorgilc

Olá pessoal meu programa dá o seguinte erro na hora da execução:

Exception in thread “main” java.lang.VerifyError: (class: teste/FormTeste, method: signature: ()V) Constructor must call super() or this()
Could not find the main class: teste.FormTeste. Program will exit.
Java Result: 1

Segue o código:

/*
 * FormTeste.java
 *
 * Created on Nov 22, 2010, 4:47:39 PM
 */
package teste;

import java.awt.Desktop;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.ArrayList;
import java.util.logging.Level;
import javax.swing.JOptionPane;
import org.jdesktop.swingx.JXErrorPane;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.decorator.HighlighterFactory;
import org.jdesktop.swingx.error.ErrorInfo;

/**
 *
 * @author victor
 */
public class FormTeste extends JFrame{

    private String abcd="abcd";
    private ClienteTableModel model;
    private String valornome;

    /** Creates new form FormTeste */
    public FormTeste()
    {
            //setResizable(false);
            initComponents();
            JXTableTeste.setColumnControlVisible(true);
            JXTableTeste.addHighlighter(HighlighterFactory.createSimpleStriping(HighlighterFactory.QUICKSILVER));
            ModelodaTabela();
            
     }

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

        jXButtonBeanInfo1 = new org.jdesktop.swingx.JXButtonBeanInfo();
        jScrollPane1 = new javax.swing.JScrollPane();
        JXTableTeste = new org.jdesktop.swingx.JXTable();
        btnAdd = new org.jdesktop.swingx.JXButton();
        btnRemove = new org.jdesktop.swingx.JXButton();
        txtNomeCategoriaCliente = new org.jdesktop.swingx.JXTextField();
        txtCodCategoriaCliente = new org.jdesktop.swingx.JXTextField();
        Nome = new org.jdesktop.swingx.JXLabel();
        jXLabel2 = new org.jdesktop.swingx.JXLabel();
        jXDatePickerDataInicial = new org.jdesktop.swingx.JXDatePicker();
        jXTaskPaneContainer1 = new org.jdesktop.swingx.JXTaskPaneContainer();
        jXTaskPane1 = new org.jdesktop.swingx.JXTaskPane();
        jXButton1 = new org.jdesktop.swingx.JXButton();
        jXButton2 = new org.jdesktop.swingx.JXButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        JXTableTeste.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {},
                {},
                {},
                {}
            },
            new String [] {

            }
        ));
        jScrollPane1.setViewportView(JXTableTeste);

        btnAdd.setText("Add");
        btnAdd.setFont(new java.awt.Font("SansSerif", 0, 10));
        btnAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddActionPerformed(evt);
            }
        });

        btnRemove.setText("Remove");
        btnRemove.setFont(new java.awt.Font("SansSerif", 0, 10));
        btnRemove.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRemoveActionPerformed(evt);
            }
        });

        Nome.setText("Nome");
        Nome.setFont(new java.awt.Font("SansSerif", 0, 10));

        jXLabel2.setText("Código");
        jXLabel2.setFont(new java.awt.Font("SansSerif", 0, 10));

        jXTaskPane1.setIcon(new javax.swing.ImageIcon("/home/victor/Área de Trabalho/Exemplos/icones teste/16_ipod.png")); // NOI18N
        jXTaskPane1.setScrollOnExpand(true);
        jXTaskPane1.setSpecial(true);
        jXTaskPane1.setTitle("Teste");
        jXTaskPane1.setFont(new java.awt.Font("SansSerif", 0, 10));

        jXButton1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jXButton1.setIcon(new javax.swing.ImageIcon("/home/victor/Área de Trabalho/Exemplos/icones teste/16_button_green.png")); // NOI18N
        jXButton1.setText("Dá erro!");
        jXButton1.setBorderPainted(false);
        jXButton1.setContentAreaFilled(false);
        jXButton1.setFont(new java.awt.Font("SansSerif", 0, 10));
        jXButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jXButton1ActionPerformed(evt);
            }
        });
        jXTaskPane1.getContentPane().add(jXButton1);

        jXButton2.setBorder(null);
        jXButton2.setIcon(new javax.swing.ImageIcon("/home/victor/Área de Trabalho/Exemplos/icones teste/16_button_purple.png")); // NOI18N
        jXButton2.setText("Vai pro Google");
        jXButton2.setBorderPainted(false);
        jXButton2.setContentAreaFilled(false);
        jXButton2.setFont(new java.awt.Font("SansSerif", 0, 10));
        jXButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jXButton2ActionPerformed(evt);
            }
        });
        jXTaskPane1.getContentPane().add(jXButton2);

        jXTaskPaneContainer1.add(jXTaskPane1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 330, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jXDatePickerDataInicial, javax.swing.GroupLayout.PREFERRED_SIZE, 164, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(12, 12, 12))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(btnRemove, javax.swing.GroupLayout.DEFAULT_SIZE, 84, Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(btnAdd, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jXLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(txtCodCategoriaCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 81, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(txtNomeCategoriaCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(Nome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                        .addComponent(jXTaskPaneContainer1, javax.swing.GroupLayout.PREFERRED_SIZE, 154, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jXDatePickerDataInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jXLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(Nome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 0, 0)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtCodCategoriaCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtNomeCategoriaCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 52, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btnRemove, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnAdd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap())
                    .addComponent(jXTaskPaneContainer1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

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

    private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {                                       
        //boolean achou = false;
        for (int i = 0; i < JXTableTeste.getRowCount(); i++) {

            String valoratual = JXTableTeste.getValueAt(i, 0) + "";

            if (valoratual.equals(txtCodCategoriaCliente.getText())) {
                //achou = true;
                JOptionPane.showMessageDialog(this, "Código já existente", "Erro", JOptionPane.ERROR_MESSAGE);
                return;
            }
        }
        String s;
        int valorcodigo;

        //if(achou==false)
        {
            if (!(txtNomeCategoriaCliente.getText().equals(""))) {
                valornome = txtNomeCategoriaCliente.getText();
                s = txtCodCategoriaCliente.getText();
                try {
                    valorcodigo = Integer.parseInt(s);

                    CatCliente p = new CatCliente(valorcodigo, valornome);

                    model.inserir(p);
                } catch (NumberFormatException e) {
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(this, "Digite um número no primeiro campo", "Erro", JOptionPane.ERROR_MESSAGE);
                }
            } else {
                JOptionPane.showMessageDialog(this, "Digite algo nos campos", "Erro", JOptionPane.ERROR_MESSAGE);
            }
        }
    }                                      

    private void btnRemoveActionPerformed(java.awt.event.ActionEvent evt) {                                          
       int selecionados[] = JXTableTeste.getSelectedRows();
        if (selecionados.length > 0) {
            ArrayList<CatCliente> seraoExcluidos = new ArrayList<CatCliente>();

            for (int i = 0; i < selecionados.length; i++) {
                seraoExcluidos.add(model.excluir(selecionados[i]));
            }

            /*seraoExcluidos.add(model.getCliente(selecionados[i]));

            for (CatCliente p : seraoExcluidos)
            seraoExcluidos.add(model.excluir(p));*/

        } else {
            JOptionPane.showMessageDialog(this, "Selecione algum item da tabela", "Erro", JOptionPane.ERROR_MESSAGE);
        }
    }                                         

    private void jXButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                          
        Desktop desk = java.awt.Desktop.getDesktop();
        try {
            desk.browse(new java.net.URI("http://www.google.com.br"));
        } catch (Exception e) {
            e.printStackTrace();
        }
}                                         

    private void jXButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                          
        try {
            int uia = Integer.parseInt(abcd);
        } catch(NumberFormatException e) {
            ErrorInfo info = new ErrorInfo("Erro","Mensagem de erro básica",null,"Categoria",
                    new Exception(), Level.ALL, null);

            JXErrorPane.showDialog(this,info);
        }
    }                                         
    private void ModelodaTabela() {

        ArrayList<CatCliente> lista = new ArrayList<CatCliente>();

        model = new ClienteTableModel(lista);

        JXTableTeste.getTableHeader().setFont(new Font("SansSerif", Font.PLAIN, 10));

        JXTableTeste.setModel(model);
    }

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

    // Variables declaration - do not modify                     
    private org.jdesktop.swingx.JXTable JXTableTeste;
    private org.jdesktop.swingx.JXLabel Nome;
    private org.jdesktop.swingx.JXButton btnAdd;
    private org.jdesktop.swingx.JXButton btnRemove;
    private javax.swing.JScrollPane jScrollPane1;
    private org.jdesktop.swingx.JXButton jXButton1;
    private org.jdesktop.swingx.JXButton jXButton2;
    private org.jdesktop.swingx.JXButtonBeanInfo jXButtonBeanInfo1;
    private org.jdesktop.swingx.JXDatePicker jXDatePickerDataInicial;
    private org.jdesktop.swingx.JXLabel jXLabel2;
    private org.jdesktop.swingx.JXTaskPane jXTaskPane1;
    private org.jdesktop.swingx.JXTaskPaneContainer jXTaskPaneContainer1;
    private org.jdesktop.swingx.JXTextField txtCodCategoriaCliente;
    private org.jdesktop.swingx.JXTextField txtNomeCategoriaCliente;
    // End of variables declaration                   

}

2 Respostas

drsmachado
[code

]public FormTeste()

{

/*

insira super() aqui

*/

super();

//setResizable(false);

initComponents();

JXTableTeste.setColumnControlVisible(true);

JXTableTeste.addHighlighter(HighlighterFactory.createSimpleStriping(HighlighterFactory.QUICKSILVER));

ModelodaTabela();
}
victorgilc

Ok, funfo, vlw

Criado 25 de novembro de 2010
Ultima resposta 25 de nov. de 2010
Respostas 2
Participantes 2