Why won't my number enter in the other box

I am writing a program for class. I have to be able to input a number in a box and then have it display in the box next to it. It also has to add the numbers everytime I put a number in the first box. I am able to get the enter button to change colors. Not sure how to get it to add and display the numbers. Also the first box has to default back to 00.0 when I click enter. Hope this is clear. Here is the code.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class FinalProject extends JFrame implements ActionListener
     public static final int WIDTH = 550;
     public static final int HEIGHT = 100;
     private JTextField myNumberOut1;
     private JTextField myNumberIn1;
     private double sum=0;
     public FinalProject()
          super("Eric Luce's Final Project");
          setSize(WIDTH, HEIGHT);
/** Setting Labels 1-3 for Stations
          JLabel myLabel1 = new JLabel ("Station Austin:");
          JLabel myLabel2 = new JLabel ("Station Amherst:");
          JLabel myLabel3 = new JLabel ("Station LaCrosse:");
/** Setting Buttons 1-3 for Adding NumberIn
          JButton myButton1 = new JButton ("Enter");
          myButton1.addActionListener(this);
          myButton1.setBackground(Color.RED);
          JButton myButton2 = new JButton ("Enter");
          myButton2.addActionListener(this);
          myButton2.setBackground(Color.WHITE);
          JButton myButton3 = new JButton ("Enter");
          myButton3.addActionListener(this);
          myButton3.setBackground(Color.BLUE);
/** Setting Labels 4-6 for Rain Fall totals
          JLabel myLabel4 = new JLabel ("Total Rainfall:");
          JLabel myLabel5 = new JLabel ("Total Rainfall:");
          JLabel myLabel6 = new JLabel ("Total Rainfall:");
/** Setting Text fields for NumberIn
          JTextField myNumberIn1 = new JTextField ("0.0", 10);
          JTextField myNumberIn2 = new JTextField ("0.0",10);
          JTextField myNumberIn3 = new JTextField ("0.0", 10);
/** Setting Text fields for NumbersOut
          JTextField myNumberOut1 = new JTextField ();
          JTextField myNumberOut2 = new JTextField ();
          JTextField myNumberOut3 = new JTextField ();
/**  Adding contents to frame line 1
          getContentPane().add(myLabel1);
          getContentPane().add(myNumberIn1);
          getContentPane().add(myButton1);
          getContentPane().add(myLabel4);
          getContentPane().add(myNumberOut1);
/** Adding contents to frame line 2
          getContentPane().add(myLabel2);
          getContentPane().add(myNumberIn2);
          getContentPane().add(myButton2);
          getContentPane().add(myLabel5);
          getContentPane().add(myNumberOut2);
/** Adding contents to frame line 3
          getContentPane().add(myLabel3);
          getContentPane().add(myNumberIn3);
          getContentPane().add(myButton3);
          getContentPane().add(myLabel6);
          getContentPane().add(myNumberOut3);
          Container contentPane = getContentPane();
          contentPane.setBackground(Color.LIGHT_GRAY);
          contentPane.setLayout(new GridLayout(3, 5));
          this.addWindowListener (new WindowAdapter()     {
               public void windowClosing(WindowEvent e)     {
     public static void main (String[] args)     {
          FinalProject mainFrame = new FinalProject();
          mainFrame.setVisible(true);
           public void actionPerformed(ActionEvent e){
               Container contentPane = getContentPane();
               if (e.getActionCommand().equals ("ENTER"));
               contentPane.setBackground(Color.RED);
/**                    sum = sum + myNumberIn1();
                    myNumberIn1.setText(Double.toString(sum));
              myNumberOut1.setText(Double.toString(sum));
               private static double stringToDouble(String stringObject)
               return Double.parseDouble(stringObject.trim());
}

I still cannot seem to get the boxes on the right to
accept the numbers I am putting in on the left. What
can I do to correct this? Please help. Thank you.You should put some code into your ActionListener to call setText on the boxes on the right. At present you don't have any, except something that is commented out.
Here's a couple of other problems, too:if (e.getActionCommand().equals ("ENTER"));First of all, that if-condition will never be true because none of your buttons have "ENTER" as their text. Several of them have "Enter" but that isn't the same thing. Even if you got the case right, this would still be a problem because you wouldn't know which button had been pressed. And finally, even if the if-condition is true, nothing will happen because you have a semi-colon at the end of it, which says "do nothing".
If you must have a single ActionListener for all those buttons, and it needs to distinguish which button was pressed, then code like this:if (e.getSource() == myButton2)will do that. However you would have to change your code to make myButton2 (etc.) instance variables of the class and not just local variables in the constructor, as they are now.

Similar Messages

  • Why won't my number highlight in the send and receive when using iMessage and FaceTime

    My imessage and facetime turned off and won't turn back on and in my send and receive section it will only highlight my email not my phone number

    Hello Torijada,
    After reviewing your post, it sounds like you linked the phone number to iMessage and iMessage wont turn on. I would recommend that you read these articles, they may be helpful in troubleshooting your issue.
    iOS and OS X: Link your phone number and Apple ID for use with FaceTime and iMessage - Apple Support
    The telephone number will be dimmed when you view these settings on an iPhone.
    If you get an error when trying to activate iMessage or FaceTime - Apple Support
    Thanks for using Apple Support Communities.
    Have a nice day,
    Mario

  • Why won't Acrobat X Pro honor the margin (art box) from PDF's exported from InDesign CS6?

    Why won't Acrobat X Pro honor the margin (art box) from PDF's exported from InDesign CS6?
    When I export a PDF from InDesign CS6 with specific margins, Acrobat does not recognize the Art box. (I have PitStop Pro 11 for page box view)

    Thanks Steve,
    We are exporting PDF's as you indicate. I see the same thing. The boxes are all the size of the original InDesign document. The PDF art box should be predicated by the margins in InDesign. When we had CS3, this worked great. Now, it seems that there is a disconnect between the two Adobe products honoring the page box size. I have contacted the Adobe techs via chat, and they had no clue what I was referring to. I find it mystifying that Acrobat can not interpret the art box set in InDesign as margins.

  • Why won't my Apple TV display the setup screen?

    Why won't my Apple TV display the setup screen? I have changed hdmi cable, confirmed the correct input, checked connection but nothing. HELP!!! I have a Bose System and use a universal remote, Logitech. Could this be a factor?

    Welcome to the Apple Community.
    What exactly does your Apple TV display.

  • How can I edit the number entered in the keypad, which I wanted to dial of iPhone4, there is no marker coming up to edit like what we have in Notes

    How can I edit the number entered in the keypad, which I wanted to dial of iPhone4, there is no marker coming up to edit like what we have in Notes

    Deepu272 wrote:
    btw does your answer mean that editing the number on keypad is not possible?
    Correct.
    Is this is the case with all the iPhone models ?
    Yep.

  • HT1338 Why won't my computer pick up the wireless in my home? All other computers in my home can get internet

    Why won't my computer pick up the wireless in my home? All other computers in my home can get the internet.

    Turn Off your computer. Then turn Off (disconnect power cord for 30 seconds or longer) the wireless router & then back On. Now boot your computer. Hopefully it will see the WiFi.
     Cheers, Tom

  • Display Dyn Textfields according to the number entered in the numericfield

    Hi all,
    In an ISR adobe form I have placed a numeric field.When the user enters a number in the numeric field , text fields corresponding to the number entered in the numeric field should be displayed dynamically.
    Can any one give me the script for doing this and also tell me in which event should I  write the code......
    Regards,
    Rheema Rahael

    Hi Rheema,
    Find the following code, which you should write on the 'Calculate' event of the field whose presence property is to be changed.
    eg.
    there is a numeric field 'NumericField1' and a text field 'TextField1'.
    Now if numeric field value is '1', hide the text field, or show the field, so i write this code in Calculate event of 'TextField1'.
    if ( NumericField1.rawValue == 1 ) {
    this.presence = "hidden"; }
    else{
    this.presence = "visible"; }
    when i input 1 in NumericField1 and press enter, the text field becomes hidden..
    when i input 2 and press enter, the text field becomes visible again.
    Thanks and Regards,
    Mona

  • How do i access iphone4. I have voice instructions requesting and speaking by password number but no password is entered in the empty boxes

    how do i access iphone4. I have voice instructions requesting password and speaking my password number but no password is entered in the empty boxes. I think that a triple tap is involved in the solution but i am stuck. Please assist.
    Brian

    https://iforgot.apple.com/

  • Why won't my screen turn when the phone does?

    why won't my screen turn when the phone does?

    Not all apps support screen rotation. The Home screens do not rotate. But also check to make sure you have not locked screen rotation. Swipe up from the bottom of the screen to reveal the Control Center and check that rotation lock is not on.

  • Why won't my iPhone connect to the Internet? It will goes days with no connection, then suddenly have a connection for a while. I am on the Sprint network.

    Why won't my iPhone connect to the Internet? It will goes days with no connection, then suddenly have a connection for a while. I am on the Sprint network.

    Have you contacted Sprint?  See if they can resolve your issue, if you can't get 3G.

  • Why won't iPhone 4 charge in the car

    Why won't iPhone 4 charge in the car anymore?  I have changed out the cords several times. It's a Belkin...bought at the apple store...not a cheapo!

    Car chargers tend to break down frequently
    buy a new one
    Strongly recommend buying on eBay a few units at a discounted price

  • Why won't my background rotate when The IPAD turns anymore

    Why won't my background rotate when The IPAD turns anymore?

    You posted this in the iPhone forum. Check in Control Center (swipe up from the home screen) and see if the rotation lock is turned on there (an icon of a lock with a circled arrow).

  • Why won't my podcasts download in the app over a Wifi connection?

    Why won't my podcasts download in the app over a Wifi connection using the Apple app on my iPhone 5?
    It works over 3G and 4G connection but every time I try to download a podcast through wifi I continually receive the message 'Download Error'.

    Hi jasonpbell,
    Thanks for visiting Apple Support Communities.
    Some of the steps in this article may help with the Wi-Fi download issue that you're seeing:
    iOS: Troubleshooting Wi-Fi networks and connections
    http://support.apple.com/kb/ts1398
    Regards,
    Jeremy

  • Why won't my iPhoto open in the latest operating system

    why won't my iPhoto open in the latest operating system

    Whcih version of iPhoto do you have? You may want to look at the Mac App Store and see if you have an update for iPhoto.
    Clinton

  • Why won't Numbers update free, when my other iWork apps have update for free?

    why won't Numbers update free, when my other iWork apps have update for free?

    I'm not sure if this answers your question. I will update them in iTunes. Then I will connect my phone and in the phone controls I can click the "Update" button and it will change to "Will Update" but doesn't.
    That's part of the problem. Once upon a time, iTunes would just automatically update apps from the computer to the phone and now it apparently requires prompting that doesn't work.

Maybe you are looking for

  • What's wrong with the scroll Bar(Urgent)

    I had a JPanel with a JTable, I put the scrollPane into the JPanel, but every time, with the mouse listener, the value of the JTable changed, but when I scroll the JTable, the value will change back to the first value which I click first time. Urgent

  • How to configure my keyboard to portuguese from brazil and can type "c̡", "é", "ã", etc?

    How can I configure my keyboard to portuguese from brazil, and can write "c̡", "á", "ã", etc ?

  • 0sold_toparty- 0sales_dist

    Hello, i have sales district as nav attribute of 0customer. i want to show data for sales district by picking it from customer master in the reports. The r/3 transactions capture 0sold_toparty (and not 0customer directly). so i created sales dist as

  • Rocketfish web camera problem

    I have iChat 4.0.5 on an older PowerMac G4 (USB 1.1) and just got a Rocketfish web camera model RF-WEB2C. On my PowerMac it indicates that the camera is in use by another application. When I plug it on a newer MacBook Pro it works fine. Is the proble

  • View Link between a recursive static View Object

    Is it Possible? I have... -MenuVO (Id, Nombre, IdPadre) I Want... -MenuFkMenuLink (Id, IdPadre) Regards