Join 300,412 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,590 people online right now. Registration is fast and FREE... Join Now!
protected JTextField equationTextfield = new JTextField(15); protected JTextField equationTextfield2 = new JTextField(15);
protected JLabel equationLabel = new JLabel("Equation #1: "); protected JLabel equationLabel2 = new JLabel("Equation #2: "); protected JLabel solutionLabel = new JLabel("Solution: ");
JLabel instructions1 = new JLabel("Please insert your two equations that you want solved of"); JLabel instructions2 = new JLabel("the formats '4x+2y=10' and '3x-8y=3'. Please use 'x' and 'y' for your variables.");
JButton solveButton = new JButton("Solve!");
JTextField solutionTextField = new JTextField(15);
The calculator compiles nicely, but when I input two equations into my calculator of correct format, I still get a BUNCH of errors that I do not understand.
Here are the errors: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at doubleVariableAlgebCalc.actionPerformed(doubleVariableAlgebCalc.java: 195) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:19 95) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.jav a:2318) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel .java:387) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242 ) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL istener.java:236) at java.awt.Component.processMouseEvent(Component.java:6263) at javax.swing.JComponent.processMouseEvent(JComponent.java:3267) at java.awt.Component.processEvent(Component.java:6028) at java.awt.Container.processEvent(Container.java:2041) at java.awt.Component.dispatchEventImpl(Component.java:4630) at java.awt.Container.dispatchEventImpl(Container.java:2099) at java.awt.Component.dispatchEvent(Component.java:4460) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574 ) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168) at java.awt.Container.dispatchEventImpl(Container.java:2085) at java.awt.Window.dispatchEventImpl(Window.java:2475) at java.awt.Component.dispatchEvent(Component.java:4460) at java.awt.EventQueue.dispatchEvent(EventQueue.java:599) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre ad.java:269) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread. java:184) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre ad.java:174) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Does anyone know what these mean? Please help.
This post has been edited by wolfman29: 3 Jul, 2009 - 03:26 PM
The first one is a Null Pointer error. Everything below it is the resulting errors of that single error. You are trying to access data that does not exist. Where that is happening I am not sure - still looking through the code.
//Solving for y System.out.println(coefficientY1); System.out.println(coefficientX2); System.out.println(coefficientY2); System.out.println(coefficientX1);
//Solving for y System.out.println(coefficientY1); System.out.println(coefficientX2); System.out.println(coefficientY2); System.out.println(coefficientX1);
You are intializing it in a if() that is probably never true put a println() everywhere you are intializing it and you will see that you never pass through that path
You are intializing it in a if() that is probably never true put a println() everywhere you are intializing it and you will see that you never pass through that path
Yeah, just tried that. See any issues of why that if() is never getting passed through?
Okay. So I just tried that, I just initialized it up at the class-level. It works nicely. However, for some reason, I cannot make either of the y-variables negative.
How do I make a Float negative? I tried multiplying it by -1, adding a minus sign in front... what?
protected JTextField equationTextfield = new JTextField(15); protected JTextField equationTextfield2 = new JTextField(15);
protected JLabel equationLabel = new JLabel("Equation #1: "); protected JLabel equationLabel2 = new JLabel("Equation #2: "); protected JLabel solutionLabel = new JLabel("Solution: ");
JLabel instructions1 = new JLabel("Please insert your two equations that you want solved of"); JLabel instructions2 = new JLabel("the formats '4x+2y=10' and '3x-8y=3'. Please use 'x' and 'y' for your variables.");
JButton solveButton = new JButton("Solve!");
JTextField solutionTextField = new JTextField(15);
//Solving for y System.out.println(coefficientX1); System.out.println(coefficientX2); System.out.println(coefficientY1); System.out.println(coefficientY2);
Okay. So I just tried that, I just initialized it up at the class-level. It works nicely. However, for some reason, I cannot make either of the y-variables negative.
How do I make a Float negative? I tried multiplying it by -1, adding a minus sign in front... what?
protected JTextField equationTextfield = new JTextField(15); protected JTextField equationTextfield2 = new JTextField(15);
protected JLabel equationLabel = new JLabel("Equation #1: "); protected JLabel equationLabel2 = new JLabel("Equation #2: "); protected JLabel solutionLabel = new JLabel("Solution: ");
JLabel instructions1 = new JLabel("Please insert your two equations that you want solved of"); JLabel instructions2 = new JLabel("the formats '4x+2y=10' and '3x-8y=3'. Please use 'x' and 'y' for your variables.");
JButton solveButton = new JButton("Solve!");
JTextField solutionTextField = new JTextField(15);