What im trying to do is to make the information outprint in the paint i made. but that is a different class so i have no clue how i would go about doing this
Code :package Algebra.Functions; import javax.swing.JOptionPane; import java.text.DecimalFormat; import java.awt.*; import Algebra.getInput; public class twostep { public static void math(Graphics2D Graphics2D) { Graphics2D g = (Graphics2D); DecimalFormat f = new DecimalFormat("#########.#########"); String First = JOptionPane.showInputDialog("Enter your Constant."); Variables.nonCoef = Double.parseDouble(First); System.out.println("[Set Up] You Entered: "+f.format(Variables.nonCoef)); //g.drawString("[Set Up] You Entered: "+f.format(Variables.nonCoef)+"", 1, 1); String Second = JOptionPane.showInputDialog("Enter Your Coeficiant."); Variables.coeficiant = Double.parseDouble(Second); System.out.println("[Set Up] You Entered: "+f.format(Variables.coeficiant)); String Third = JOptionPane.showInputDialog("Enter Number right of ="); Variables.equationEquals = Double.parseDouble(Third); System.out.println("[Set Up] You Entered: "+f.format(Variables.equationEquals)); Variables.fstans = ((double) (Variables.equationEquals - Variables.nonCoef)); Variables.xeqls = ((double) (Variables.fstans / Variables.coeficiant)); System.out.println("...................................."); System.out.println("[Set Up] Your Equation is: "+f.format(Variables.nonCoef)+"+"+f.format(Variables.coeficiant)+"x="+f.format(Variables.equationEquals)); System.out.println("...................................."); System.out.println("[Step 1] "+f.format(Variables.equationEquals)+"-"+f.format(Variables.nonCoef)); System.out.println("[Step 1 Explanation] Subtract the nonCoefber with no varible from..."); System.out.println("...the nonCoefber on right of equal sing, and remove."); System.out.println("...................................."); System.out.println("[Equation] "+f.format(Variables.coeficiant)+"x="+f.format(Variables.fstans)); System.out.println("[Step 2] "+f.format(Variables.fstans)+"/"+f.format(Variables.coeficiant)); System.out.println("[Step 2 Explanation] Devide the nonCoef. to the right of = by the coefitant..."); System.out.println("...what remains is the vaule of your variable!"); System.out.println("...................................."); System.out.println("[Awnser] x = "+f.format(Variables.xeqls)); getInput.Equations(); } }
change System.out.println to drawString but when i do it it crashes.
heres my painting class
Code :package Algebra; import java.awt.*; import javax.swing.*; @SuppressWarnings("serial") public class Painting extends JPanel { public Painting() { setBackground(Color.CYAN); } public void paintComponet(Graphics g) { super.paintComponent(g); } }
and from here idk what to do.. idk if you understand what im trying to say or not but yeah.. idk what else to say
heres the error
Code :Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at Algebra.Functions.twostep.math(twostep.java:17) at Algebra.getInput.Equations(getInput.java:23) at Algebra.GUI.actionPerformed(GUI.java:74) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$000(Unknown Source) at java.awt.EventQueue$1.run(Unknown Source) at java.awt.EventQueue$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source) at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue$2.run(Unknown Source) at java.awt.EventQueue$2.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)
