4
I am developing in Netbeans IDE when running through the IDE everything works fine but when I do clean and build
and create . jar while executing casts me this exception:
I tried to compile package by package but it still didn’t work.
Any suggestions to fix this problem?
Editing this is the class that the bug says is missing, I already checked and the file . class is in the jar, Is there an error that the compiler cannot catch?
package gui.Admin;
import Models.Loteestado;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;
public class LoteEstadoTableModelTESTE extends AbstractTableModel{
private List<Loteestado> lotes;
private String[] colunas = new String[] {
"lote","ok|nok","Produto","Qtd Total", "Qtd","Progresso"};
public LoteEstadoTableModelTESTE() {
lotes = new ArrayList<Loteestado>();
}
public LoteEstadoTableModelTESTE(List<Loteestado> lote) {
lotes = new ArrayList<Loteestado>(lote);
}
@Override
public int getColumnCount() {
return colunas.length;
}
@Override
public int getRowCount() {
return lotes.size();
}
@Override
public String getColumnName(int columnIndex) {
return colunas[columnIndex];
};
@Override
public Class<?> getColumnClass(int columnIndex) {
switch (columnIndex) {
case 0:
return String.class;
case 1: // RETURN OK OU NOK.
return String.class;
case 2: //PRODUTO
return String.class;
case 3: // MAX
return Integer.class;
case 4: // REALIZADO
return Integer.class;
case 5: // progress bar
return Integer.class;
default:
// Se o índice da coluna não for válido, lança um
// IndexOutOfBoundsException (Exceção de índice fora dos limites).
// Não foi necessário verificar se o índice da linha é inválido,
// pois o próprio ArrayList lança a exceção caso seja inválido.
throw new IndexOutOfBoundsException("columnIndex out of bounds");
}
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
Loteestado lote = lotes.get(rowIndex);
switch (columnIndex) {
case 0:
return lote.getLinha();
case 1: //Primeira coluna é o nome.
{ String estado="";
if (lote.getQtdrealizada() > 10 && lote.getQtdrealizada() <= lote.getQtdtotal() / 2 && lote.getAlrinicio() == false)
estado="NOK";
else if (lote.getQtdrealizada() > 10 && lote.getQtdrealizada() >= lote.getQtdtotal() / 2 && lote.getAlrfim() == false)
estado="NOK";
else estado="OK";
return estado;
}
case 2: // Primeira coluna é o nome.
return lote.getProduto().getNoproduto();
case 3: // Segunda coluna qtd realizada.
return lote.getQtdtotal();
case 4: // Segunda coluna é a qtd total.
return lote.getQtdrealizada();
case 5: // Segunda coluna é a qtd total.
if(lote.getQtdtotal() != 0) return ((lote.getQtdrealizada() * 100) /lote.getQtdtotal());
else return 0;
default:
// Se o índice da coluna não for válido, lança um
// IndexOutOfBoundsException (Exceção de índice fora dos limites).
// Não foi necessário verificar se o índice da linha é inválido,
// pois o próprio ArrayList lança a exceção caso seja inválido.
throw new IndexOutOfBoundsException("columnIndex out of bounds");
}
}
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
Loteestado lote = lotes.get(rowIndex);
if (columnIndex == 0) {
lote.setLinha(aValue.toString());
}
if (columnIndex == 2) {
lote.getProduto().setNoproduto(aValue.toString());
}
if (columnIndex == 3) {
lote.setQtdtotal((int)aValue);
}
if (columnIndex == 4) {
lote.setQtdrealizada((int)aValue);
}
};
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
return false;
}
public Loteestado getlinha(int indiceLinha) {
return lotes.get(indiceLinha);
}
// public void ActuaLinha(){
// linhas.set(removeLinha(indiceLinha), null)
// }
public void addLinha(Loteestado linha) {
// Adiciona o registro.
lotes.add(linha);
int ultimoIndice = getRowCount() - 1;
fireTableRowsInserted(ultimoIndice, ultimoIndice);
}
public void removeLinha(int indiceLinha) {
lotes.remove(indiceLinha);
fireTableRowsDeleted(indiceLinha, indiceLinha);
}
public boolean IsContem(Loteestado lot){
for(Loteestado lote:lotes)
if(lote.getProduto().equals(lot.getProduto()))return true;
return false;
}
public void addListaDeLinhas(List<Loteestado> linhass) {
int tamanhoAntigo = getRowCount();
lotes.addAll(linhass);
fireTableRowsInserted(tamanhoAntigo, getRowCount() - 1);
}
public boolean procuraNome(Loteestado lote){
if(lotes.contains(lote)){return true;}
else {return false;}
}
public void actualizaLista(Loteestado lote){
if(lotes.contains(lote)){
for(Loteestado item : lotes){
if(item.equals(lote)) {lotes.set(lotes.indexOf(item), lote); fireTableRowsUpdated(lotes.indexOf(item), lotes.indexOf(item));}
}
}
else {lotes.add(lote); fireTableRowsUpdated(lotes.indexOf(lote), lotes.indexOf(lote));}
}
public void limpar() {
lotes.clear();
fireTableDataChanged();
}
public boolean isEmpty() {
return lotes.isEmpty();
}
}
After that I make normal use of it:
jTblLinhasOnline.setModel(new LoteEstadoTableModelTESTE());
Hang on, you can help me?
Issue 2
I copied the class for the class SoftwareGui
and it worked, yet if anyone knew the other resolution they preferred...
The class
gui.tabelasLinhasonline.TesteLoteEstadoTableModel
is there? Is it in a JAR in the classpath? Is there a capitalization error on it (this capital L in the package name is suspicious)? Is there a typo in it (eg it should beLinha
instead ofLinhas
)?– Victor Stafusa
@Victor no. jar that creates this class is there, in one of the attempts to solve the problem I changed her name "Testeloteestadotablemodel" and I saw that I had a problem because the word started with lowercase letter, I corrected but gave the same error again... However I will re-examine this possibility of typo
– jsantos1991
@Victor I’ve changed the name, I’ve changed the board of this class, I’ve copied it to a new class with a different name but still I’m not getting it, I don’t understand why
– jsantos1991
Then post the code of
GUI.SoftwareGUI
to make sure she doesn’t do anything too bizarre. But before that, it’s worth recompiling everything from scratch with a clean environment.– Victor Stafusa
@Victor "clean environment" what do you mean? create a new project and send this one inside? I am now thinking about another possible problem I started this project in netbeans 7 and now I am working on 8 on another computer will be may be this?
– jsantos1991
Clean environment means to erase all ". class" and all jars that are generated by the compilation process. Finally have only the sources, classpath Jars and other necessary files that the compiler does not use (such as
pom.xml
, figures, configuration files, etc).– Victor Stafusa
Everything goes wrong, in netbenas there is an option that says "inspect" only for that I had to install a "plugin" now netbeans does not start large mer***... these files . class are in the right "build" folder?
– jsantos1991
Just giving a "Clean and Build" should be enough. You don’t need any plugin for this. But yes, they should be in the folder
build
. And the Jars generated in the folderdist
. Delete everything inside these folders, leaving them empty.– Victor Stafusa