@andrea:
java.lang.NullPointerException
quindi?
@andrea:
java.lang.NullPointerException
quindi?
quindi non hai fatto quello che ti ho suggerito di fare, visto che era l'esatto problema che avevo io e l'ho risolto mettendo tutto insieme.
<´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
"The answer to your question is: welcome to tomorrow"
ho fatto cm hai detto tu ma niente nn funzia lo stesso :|Originariamente inviato da Andrea1979
quindi non hai fatto quello che ti ho suggerito di fare, visto che era l'esatto problema che avevo io e l'ho risolto mettendo tutto insieme.
ti posso postare il mio output
nella cartella javamath ho solo la classe Main.class il cui codice sorgente è quello postato sopra.codice:E:\Documents and Settings\Andrea\Documenti\Netbeans Projects\JavaMath\build>cd c lasses E:\Documents and Settings\Andrea\Documenti\Netbeans Projects\JavaMath\build\clas ses>dir Il volume nell'unità E è Andrea Numero di serie del volume: 28CF-93FE Directory di E:\Documents and Settings\Andrea\Documenti\Netbeans Projects\JavaM ath\build\classes 23/09/2007 23.45 <DIR> . 23/09/2007 23.45 <DIR> .. 23/09/2007 23.45 <DIR> com 23/09/2007 23.45 <DIR> images 23/09/2007 23.12 <DIR> javamath 0 File 0 byte 5 Directory 20.378.602.496 byte disponibili E:\Documents and Settings\Andrea\Documenti\Netbeans Projects\JavaMath\build\clas ses>java javamath/Main Abs.class ACos.class ASin.class ATan.class Cos.class NaturalLogarithm.class Sign.class Sin.class Sqrt.class Tan.class Divide.class Minus.class Mod.class Mul.class Plus.class Pow.class UMinus.class UPlus.class E.class PI.class 18.0 E:\Documents and Settings\Andrea\Documenti\Netbeans Projects\JavaMath\build\clas ses>
<´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
"The answer to your question is: welcome to tomorrow"
come puoi vedere ho un package - javamath - con la mia classe, e l'altro - com - con la libreria (la cartella images non serve ad una pippa credo, ma per non sbagliare l'ho copiata lo stesso). Niente altro.
<´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
"The answer to your question is: welcome to tomorrow"
ho fatto la stessa identica cosa...ma niente sempre quell'eccezione mi daOriginariamente inviato da Andrea1979
come puoi vedere ho un package - javamath - con la mia classe, e l'altro - com - con la libreria (la cartella images non serve ad una pippa credo, ma per non sbagliare l'ho copiata lo stesso). Niente altro.![]()
Ah, la com è la mia, quella compilata da me dai sorgenti. Ho JDK/JRE 6
<´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
"The answer to your question is: welcome to tomorrow"
vabbe allora l'errore starà nel codice...
ecco il pezzo di codice del mio programma ke fa utilizzo di javamath:
codice:/* * createM.java * * Created on 23 settembre 2007, 13.35 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package school; import javax.swing.*; import java.awt.event.*; import java.awt.*; import com.grug.math.parsing.MathParser; import com.grug.math.*; /** * * @author Giordano */ public class createM { static double value; /** Creates a new instance of createM */ public createM() { final JFrame m=new JFrame("Crea mastro"); final JTextField val,valf,name; JButton ok,cancel; final JRadioButton r1,r2,r3,r4; Container cm=m.getContentPane(); JPanel cmp=new JPanel(); ButtonGroup bg = new ButtonGroup(); ButtonGroup bg2=new ButtonGroup(); cm.add(cmp); name=new JTextField("Nome conto",20); val=new JTextField("Importo",20); valf=new JTextField("Formula",20); val.setEnabled(false); valf.setEnabled(false); r1=new JRadioButton(); r2=new JRadioButton(); bg2.add(r1); bg2.add(r2); r1.addItemListener(new ItemListener(){ public void itemStateChanged(ItemEvent e){ val.setEnabled(true); } }); r2.addItemListener(new ItemListener(){ public void itemStateChanged(ItemEvent e){ valf.setEnabled(true); } }); ok=new JButton("ok"); ok.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ m.setVisible(false); if (r1.isSelected()){ value=Double.parseDouble(val.getText().trim()); System.out.println(value); } if(r2.isSelected()){ try{ String s=valf.getText(); MathParser mp=new MathParser(); Expression ex=mp.parse(s); value=ex.compute(null); System.out.println(value); } catch(Exception exc){ exc.printStackTrace(); } } } }); cancel=new JButton("annulla"); cancel.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ m.setVisible(false); } }); r3=new JRadioButton("Dare"); r4=new JRadioButton("Avere"); bg.add(r3); bg.add(r4); cmp.setLayout(new FlowLayout()); cmp.add(name);cmp.add(r3);cmp.add(r4); cmp.add(r1);cmp.add(val); cmp.add(r2);cmp.add(valf); cmp.add(ok);cmp.add(cancel); m.pack(); m.setLocationRelativeTo(null); m.setVisible(true); } }
La tua classe funziona. Eseguila a mano da finestra di dos, chiaramente aggiungendo un main...
<´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
"The answer to your question is: welcome to tomorrow"