Results 1 to 2 of 2
  1. #1
    cyentw is offline Member
    Join Date
    Jan 2013
    Posts
    14
    Rep Power
    0

    Default Help with Adder GUI

    Ok, so I started a project which is a GUI which adds two numbers together (so far)

    I am having trouble with something when I press the "add" button.

    Here is the code which is causing problems:
    Java Code:
    public void actionPerformed(ActionEvent e) {
    	
    	if (e.getSource()==add)
    	{
    		if(i==0)
    		{
    			calccontentconvert = calc.getText();
    			calccontent[i] = Integer.valueOf(calccontentconvert);
    			calc.setText("");
    			i++;
    		}
    		else
    		{
    			calccontentconvert = calc.getText();
    			calccontent[i] = Integer.valueOf(calccontentconvert);
    			answer = calccontent[i] + calccontent[i-1];
    			calccontentconvert = String.valueOf (answer);
    			calc.setText(calccontentconvert);
    			i=0;
    		}
    		
    	}
    }
    Here are all the relevant variables and components:

    Java Code:
    private JButton add = new JButton("plus");
    private JTextField calc = new JTextField(" ");
    public int i;
    private String calccontentconvert = "";
    private int[] calccontent = new int[100];
    private int answer;
    I would love for someone to teach me which button adds a 'Spoiler' to the page so I can post the lengthy error report it sends me :)

    Thanks!

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default Re: Help with Adder GUI

    Post the exact error message/ stack trace you see and include a SSCCE.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

Similar Threads

  1. In-Range adder
    By filem_funk in forum New To Java
    Replies: 1
    Last Post: 11-27-2009, 02:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •