To com um problema, quando tento somar linhas de uma jTable.
Estou usando o netBeans, usei a tabela criada pelo propio netbeans
EU tenho o dado Replicacao que seria o tanto de linhas que tem na tabela
Ele consegue somar td, mas ele da um problema com a ultima linha, ele nao consegue pegar a ultima linha da tabela? qq eu faco??
Fikei testando ele tentar imprimir o ultimo valor mas ele da pau!
private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
Double Média = 0.0;
Double Total = 0.0;
Object Valor = new Object();
String val = new String();
Integer Replicacao = new Integer (jTextField3.getText());
for (int i = 0; i < Replicacao; i++)
{
Valor = jTable1.getValueAt(i,0);
val = Valor.toString();
Double num = new Double (val);
System.out.println (num);
Total = Total + num;
}
Média = Total/Replicacao;
jTextField1.setText(Média.toString());
}
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at sistemasterminais.Tela.jButton1MouseClicked(Tela.java:199)
at sistemasterminais.Tela.access$000(Tela.java:13)
at sistemasterminais.Tela$1.mouseClicked(Tela.java:55)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:253)
at java.awt.Component.processMouseEvent(Component.java:6044)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5806)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4413)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4243)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3995)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2440)
at java.awt.Component.dispatchEvent(Component.java:4243)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)