Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 18 of 18

Thread: drawString

  1. #1
    Member
    Join Date
    Jan 2011
    Posts
    88
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Question drawString

    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

    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

    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

    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)
    Last edited by frozen java; June 14th, 2011 at 02:32 PM.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,330
    Thanks
    181
    Thanked 829 Times in 772 Posts
    Blog Entries
    5

    Default Re: drawString

    I presume you wish to use the paintComponent method...check your spelling.
    change System.out.println to drawString but when i do it it crashes
    Crashes where? What is the full stack trace? Ultimately it helps to post an SSCCE which clearly demonstrates the problem

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    20,973
    Thanks
    51
    Thanked 2,269 Times in 2,241 Posts

    Default Re: drawString

    When you get errors, it helps us solve the problem if you post all of the text of the error message here.

  4. #4
    Member
    Join Date
    Jan 2011
    Posts
    88
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Re: drawString

    ok i added the error it get

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    20,973
    Thanks
    51
    Thanked 2,269 Times in 2,241 Posts

    Default Re: drawString

    Now you need to learn to read the stack trace.
    Look at these lines starting at the bottom:
    PHP Code:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        at Algebra
    .Functions.twostep.math(twostep.java:17)  << at line 17 there is a null variable !!!!
        
    at Algebra.getInput.Equations(getInput.java:23)   << Equations calls getInput at line 23 
        at Algebra
    .GUI.actionPerformed(GUI.java:74)   <<<<<<<<< GUI line 23 calls Equations 
    What is the variable with the null value at line 17 in twostep?
    When you find the variable, trace back thru your code to see why that variable does not have a value.

  6. #6
    Member
    Join Date
    Jan 2011
    Posts
    88
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Re: drawString

    that variable is defined by the user it has a value but for some reason drawString isnt recognizing it

  7. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    20,973
    Thanks
    51
    Thanked 2,269 Times in 2,241 Posts

    Default Re: drawString

    Defining a variable does not give it a value (except for primitives).
    What variable is null?
    Where does your code assign a value to the variable.

    drawString isnt recognizing it
    drawString is a method of the Graphics class. Is one of its arguments null? If that were true, the error message that you posted would show that you had called the drawString method and that the error occurred in the drawString method's code.

  8. #8
    Member
    Join Date
    Jan 2011
    Posts
    88
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Re: drawString

    would this be causing the problem?

    twostep.math(null);

    that is in the getInput class

  9. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    20,973
    Thanks
    51
    Thanked 2,269 Times in 2,241 Posts

    Default Re: drawString

    yes it would if the variable twostep is null. Or if the math() method expects to receive a value other than null.

  10. #10
    Member
    Join Date
    Jan 2011
    Posts
    88
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Re: drawString

    so what would need to go in place of that?

  11. #11
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    20,973
    Thanks
    51
    Thanked 2,269 Times in 2,241 Posts

    Default Re: drawString

    To get a graphics object, use the one passed to the paintComponent() method. Call the math() method from paintComponent() and use the Graphics object it receives as math()'s argument.

  12. #12
    Member
    Join Date
    Jan 2011
    Posts
    88
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Re: drawString

    ok so in paintComponet i called twostep.math(g)

    	public void paintComponet(Graphics2D g) {
    		super.paintComponent(g);
    		twostep.math(g);
    	}

    in getInput i was still having a problem with. it sayed:
    Graphics2D cannot be resolved	AlgebraCalculator/src/Algebra	getInput.java	line 26

    i used one of the quick fix options (im using eclipse) and it says create a field for Grafics2D

    witch is
    private static Graphics2D Graphics2D;

    heres my getInput class

    package Algebra;
     
    import java.awt.Graphics2D;
     
    import javax.swing.JOptionPane;
    import Algebra.Functions.*;
     
    public class getInput {
     
     
    	private static Graphics2D Graphics2D;
    	public static void Equations() {
    	int size = 0;
    		while (size < 1) {
    			String Choose = JOptionPane
    					.showInputDialog("One or Two Step Equation?");
    			size = Integer.parseInt(Choose);
    			System.out.println("Your Equation will be a " + size
    					+ " Step Equation!");
     
    			if (size == 1) {
    				onestep.math();
    			}
     
    			if (size == 2) {
    				twostep.math(Graphics2D);
    			}
     
    			if ((size > 2) || (size < 1)) {
    				System.out.println("I'm sorry but equation size " + size
    						+ " is not currently compatible!");
    				size = 0;
    			}
    		}
    	}
    	public static void Area() {
    		int shape = 0;
    		String Choose = JOptionPane
    			.showInputDialog("One or Two Step Equation?");
    		shape = Integer.parseInt(Choose);
     
    		if (shape == 1) {
    			area.Rectangle();
    		}
    	}
     
    }

    it still crashes how ever and here is the there

    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    	at Algebra.Functions.twostep.math(twostep.java:17)
    	at Algebra.getInput.Equations(getInput.java:26)
    	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)

  13. #13
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    20,973
    Thanks
    51
    Thanked 2,269 Times in 2,241 Posts

    Default Re: drawString

    Graphics2D cannot be resolved

    Do you have the correct import statement?

  14. #14
    Member
    Join Date
    Jan 2011
    Posts
    88
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Re: drawString

    im importing
    import java.awt.Graphics2D;

    into getInput wich is correct

  15. #15
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    20,973
    Thanks
    51
    Thanked 2,269 Times in 2,241 Posts

    Default Re: drawString

    At this point, you need to post code that compiles and executes and demonstrates the problem.
    I can't make sense out of all the bits and pieces you've been posting. I need to see a complete program that demonstrates the problem.

    To get the graphics object, you need to be in the paintComponent class and call the methods that will do the drawing from there. Pass them the graphics object passed to the paintComponent method.

  16. #16
    Member
    Join Date
    Jan 2011
    Posts
    88
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Re: drawString

    ok heres all the classes involved:

    getInput:
    package Algebra;
     
    import java.awt.Graphics2D;
     
    import javax.swing.JOptionPane;
    import Algebra.Functions.*;
     
    public class getInput {
     
     
    	private static Graphics2D Graphics2D;
    	public static void Equations() {
    	int size = 0;
    		while (size < 1) {
    			String Choose = JOptionPane
    					.showInputDialog("One or Two Step Equation?");
    			size = Integer.parseInt(Choose);
    			System.out.println("Your Equation will be a " + size
    					+ " Step Equation!");
     
    			if (size == 1) {
    				onestep.math();
    			}
     
    			if (size == 2) {
    				twostep.math(Graphics2D);
    			}
     
    			if ((size > 2) || (size < 1)) {
    				System.out.println("I'm sorry but equation size " + size
    						+ " is not currently compatible!");
    				size = 0;
    			}
    		}
    	}
    	public static void Area() {
    		int shape = 0;
    		String Choose = JOptionPane
    			.showInputDialog("One or Two Step Equation?");
    		shape = Integer.parseInt(Choose);
     
    		if (shape == 1) {
    			area.Rectangle();
    		}
    	}
     
    }

    Painting:
    package Algebra;
     
    import java.awt.*;
    import javax.swing.*;
    import Algebra.Functions.*;
     
    @SuppressWarnings("serial")
    public class Painting extends JPanel {
     
    	public Painting() {
    		setBackground(Color.CYAN);
    	}
     
    	public void paintComponet(Graphics2D g) {
    		super.paintComponent(g);
    		twostep.math(g);
    	}
    }

    twostep:
    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();
    	}
     
    }

    and GUI:
    package Algebra;
     
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
     
    import Algebra.getInput;
     
    public class GUI implements ActionListener {
     
    	// Create Frame
    	private JFrame f = new JFrame("Joshs' Algebra Calculator");
     
    	// Create Panels
    	private JPanel funcPnl = new JPanel();
    	//private JTextField txtNotes = new JTextField();
     
    	// Buttons
    	private JButton algButton = new JButton("Equations");
    	private JButton areaButton = new JButton("Area");
     
    	// Create Menu
    	private JMenuBar mb = new JMenuBar();
    	private JMenu muFile = new JMenu("File");
    	private JMenuItem muItemQuite = new JMenuItem("Quit");
    	private JMenu muHelp = new JMenu("Help");
    	private JMenuItem muItemAbout = new JMenuItem("About");
     
    	public GUI() {
    		// set menu
    		f.setJMenuBar(mb);
     
    		// build menu
    		muFile.add(muItemQuite);
    		muHelp.add(muItemAbout);
    		mb.add(muFile);
    		mb.add(muHelp);
     
    		// Add Buttons
    		funcPnl.add(algButton);
    		funcPnl.add(areaButton);
     
    		// Set Up Frame
     
    		f.setSize(400, 300);
    		f.getContentPane().setLayout(new BorderLayout());
    		f.getContentPane().add(funcPnl, BorderLayout.WEST);
    		//f.getContentPane().add(txtNotes, BorderLayout.SOUTH);
     
    		// Allows the Swing App to be closed
    		f.addWindowListener(new ListenCloseWdw());
     
    		// Add Menu & Button listener
    		muItemQuite.addActionListener(new ListenMenuQuit());
    		muItemAbout.addActionListener(this);
    		algButton.addActionListener(this);
    		areaButton.addActionListener(this);
     
    		// Buttons
    		muItemAbout.setActionCommand("About");
    		algButton.setActionCommand("Algebra");
    		areaButton.setActionCommand("Area");
    	}
     
    	@Override
    	public void actionPerformed(ActionEvent e) {
    		String cmd = e.getActionCommand();
    		if (cmd != null) {
    			if (cmd.equalsIgnoreCase("About")) {
    				JOptionPane.showMessageDialog(f,
    						"This Software is made by Josh Artuso");
    			}
    			if (cmd.equalsIgnoreCase("Algebra")) {
    				getInput.Equations();
    			}
    			if (cmd.equalsIgnoreCase("Area")) {
    				getInput.Area();
    			}
    		}
    	}
     
    	public class ListenMenuQuit implements ActionListener {
    		public void actionPerformed(ActionEvent e) {
    			System.exit(0);
    		}
    	}
     
    	public class ListenCloseWdw extends WindowAdapter {
    		public void windowClosing(WindowEvent e) {
    			System.exit(0);
    		}
    	}
     
    	public void launchFrame() {
    		// Display Frame
    		Painting panel = new Painting();
    		Container pane = f.getContentPane();
    		pane.setLayout(new GridLayout (1,1));
    		pane.add(panel);
    		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		f.setVisible(true);
    		f.setResizable(false);
    		f.setIconImage(Toolkit.getDefaultToolkit().getImage("favicon.gif"));
    	}
     
    	public static void main(String args[]) {
    		GUI gui = new GUI();
    		gui.launchFrame();
    	}
    }

    GUI is the main class

  17. #17
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    20,973
    Thanks
    51
    Thanked 2,269 Times in 2,241 Posts

    Default Re: drawString

    private static Graphics2D Graphics2D;
    math(Graphics2D Graphics2D)
    This is bad!!! The variable name is the same as the type name. Variables should start with lowercase.

    The code is missing many variable definitions. I get 26 compile errors:

    Running: D:\Java\jdk1.6.0_25\bin\javac.exe -Xlint -g -deprecation -classpath D:\JavaDevelopment\;. GUI_Problem.java

    GUI_Problem.java:47: cannot find symbol
    symbol : variable area
    location: class GUI_Problem.getInput
    area.Rectangle();
    ^
    GUI_Problem.java:53: warning: [serial] serializable class GUI_Problem.Painting has no definition of serialVersionUID
    static class Painting extends JPanel {
    ^
    GUI_Problem.java:68: cannot find symbol
    symbol : class DecimalFormat
    location: class GUI_Problem.twostep
    DecimalFormat f = new DecimalFormat("#########.#########");
    ^
    GUI_Problem.java:68: cannot find symbol
    symbol : class DecimalFormat
    location: class GUI_Problem.twostep
    DecimalFormat f = new DecimalFormat("#########.#########");
    ^
    GUI_Problem.java:70: cannot find symbol
    symbol : variable Variables
    location: class GUI_Problem.twostep
    Variables.nonCoef = Double.parseDouble(First);
    ^
    GUI_Problem.java:71: cannot find symbol
    symbol : variable Variables
    location: class GUI_Problem.twostep
    System.out.println("[Set Up] You Entered: "+f.format(Variables.nonCoef));
    ^
    GUI_Problem.java:72: cannot find symbol
    symbol : variable Variables
    location: class GUI_Problem.twostep
    g.drawString("[Set Up] You Entered: "+f.format(Variables.nonCoef)+"", 1, 1);
    ^
    GUI_Problem.java:75: cannot find symbol
    symbol : variable Variables
    location: class GUI_Problem.twostep
    Variables.coeficiant = Double.parseDouble(Second);
    ^
    GUI_Problem.java:76: cannot find symbol
    symbol : variable Variables
    location: class GUI_Problem.twostep
    System.out.println("[Set Up] You Entered: "+f.format(Variables.coeficiant));
    ^
    GUI_Problem.java:79: cannot find symbol
    symbol : variable Variables
    location: class GUI_Problem.twostep
    Variables.equationEquals = Double.parseDouble(Third);
    ^
    GUI_Problem.java:80: cannot find symbol
    symbol : variable Variables
    location: class GUI_Problem.twostep
    System.out.println("[Set Up] You Entered: "+f.format(Variables.equationEquals));
    ^
    GUI_Problem.java:82: cannot find symbol
    symbol : variable Variables
    location: class GUI_Problem.twostep
    Variables.fstans = ((double) (Variables.equationEquals - Variables.nonCoef));
    ^
    GUI_Problem.java:82: cannot find symbol
    symbol : variable Variables
    location: class GUI_Problem.twostep
    Variables.fstans = ((double) (Variables.equationEquals - Variables.nonCoef));
    ^
    GUI_Problem.java:82: cannot find symbol
    symbol : variable Variables
    location: class GUI_Problem.twostep
    Variables.fstans = ((double) (Variables.equationEquals - Variables.nonCoef));
    ^
    GUI_Problem.java:83: cannot find symbol
    symbol : variable Variables
    location: class GUI_Problem.twostep
    Variables.xeqls = ((double) (Variables.fstans / Variables.coeficiant));
    ^
    GUI_Problem.java:83: cannot find symbol
    symbol : variable Variables
    location: class GUI_Problem.twostep
    Variables.xeqls = ((double) (Variables.fstans / Variables.coeficiant));
    ^
    GUI_Problem.java:83: cannot find symbol
    symbol : variable Variables
    location: class GUI_Problem.twostep
    Variables.xeqls = ((double) (Variables.fstans / Variables.coeficiant));
    ^
    GUI_Problem.java:86: cannot find symbol
    symbol : variable Variables
    location: class GUI_Problem.twostep
    System.out.println("[Set Up] Your Equation is: "+f.format(Variables.nonCoef)+"+"+f.format(Variabl es.coeficiant)+"x="+f.format(Variables.equationEqu als));
    ^
    GUI_Problem.java:86: cannot find symbol
    symbol : variable Variables
    location: class GUI_Problem.twostep
    System.out.println("[Set Up] Your Equation is: "+f.format(Variables.nonCoef)+"+"+f.format(Variabl es.coeficiant)+"x="+f.format(Variables.equationEqu als));
    ^
    GUI_Problem.java:86: cannot find symbol
    symbol : variable Variables
    location: class GUI_Problem.twostep
    System.out.println("[Set Up] Your Equation is: "+f.format(Variables.nonCoef)+"+"+f.format(Variabl es.coeficiant)+"x="+f.format(Variables.equationEqu als));
    ^
    GUI_Problem.java:88: cannot find symbol
    symbol : variable Variables
    location: class GUI_Problem.twostep
    System.out.println("[Step 1] "+f.format(Variables.equationEquals)+"-"+f.format(Variables.nonCoef));
    ^
    GUI_Problem.java:88: cannot find symbol
    symbol : variable Variables
    location: class GUI_Problem.twostep
    System.out.println("[Step 1] "+f.format(Variables.equationEquals)+"-"+f.format(Variables.nonCoef));
    ^
    GUI_Problem.java:92: cannot find symbol
    symbol : variable Variables
    location: class GUI_Problem.twostep
    System.out.println("[Equation] "+f.format(Variables.coeficiant)+"x="+f.format(Var iables.fstans));
    ^
    GUI_Problem.java:92: cannot find symbol
    symbol : variable Variables
    location: class GUI_Problem.twostep
    System.out.println("[Equation] "+f.format(Variables.coeficiant)+"x="+f.format(Var iables.fstans));
    ^
    GUI_Problem.java:93: cannot find symbol
    symbol : variable Variables
    location: class GUI_Problem.twostep
    System.out.println("[Step 2] "+f.format(Variables.fstans)+"/"+f.format(Variables.coeficiant));
    ^
    GUI_Problem.java:93: cannot find symbol
    symbol : variable Variables
    location: class GUI_Problem.twostep
    System.out.println("[Step 2] "+f.format(Variables.fstans)+"/"+f.format(Variables.coeficiant));
    ^
    GUI_Problem.java:97: cannot find symbol
    symbol : variable Variables
    location: class GUI_Problem.twostep
    System.out.println("[Awnser] x = "+f.format(Variables.xeqls));
    ^
    26 errors
    1 warning

    27 error(s)
    Last edited by Norm; June 14th, 2011 at 04:32 PM.

  18. #18
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    20,973
    Thanks
    51
    Thanked 2,269 Times in 2,241 Posts

    Default Re: drawString

    Try to make a small simple program that compiles and executes to display the problem.
    Don't bother to post more of this large, multi part code.
    It needs to demonstrate only what the problem is. The rest is just in the way.

Similar Threads

  1. [SOLVED] How to make a more than one line JLabel or drawString for more than one line.
    By javapenguin in forum What's Wrong With My Code?
    Replies: 9
    Last Post: June 4th, 2011, 02:16 PM
  2. drawString and JTextField
    By that_guy in forum AWT / Java Swing
    Replies: 9
    Last Post: January 29th, 2011, 01:43 AM
  3. [SOLVED] font size and other attributes for Graphics.drawString()
    By gib65 in forum AWT / Java Swing
    Replies: 2
    Last Post: October 30th, 2010, 02:31 PM
  4. Click to start and drawString fonts
    By Campos in forum Java Applets
    Replies: 3
    Last Post: July 24th, 2009, 02:24 PM

Tags for this Thread