Re: PLEASE HELP:Calculator: I need help building a swing calculator.
From: Peter Pein (nospam_at_spam.no)
Date: 02/09/04
- Next message: Thomas Weidenfeller: "comp.lang.java.gui FAQ"
- Previous message: Andrew Thompson: "Re: GridBagLayout: can not make a component bigger"
- In reply to: Rafael: "PLEASE HELP:Calculator: I need help building a swing calculator."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 9 Feb 2004 07:13:15 +0100
"Rafael" <spawn@rloteck.com> schrieb im Newsbeitrag
news:a55917dc.0402071158.43631de9@posting.google.com...
> Hi Everyone,
>
> I am trying to build a swing application that adds three
> jTextFields. However, I am runnning in to all kinds of issues. Here is
> the code I am placing on the button that is processing the addtion I
> want it to do:
>
>
> private void jButton1ActionPerformed(java.awt.event.ActionEvent
> evt) {
> //gets numbers from jTextFields
> int num1 = jTextField1.getInt();
> int num2 = jTextField2.getInt();
> int num3 = jTextField3.getInt();
>
> //Adds num1, num2 and num3 together.
> num4 = num1 + num2 + num3;
>
> //puts total
> int num4 = jTextField4.putInt();
>
>
> }
> ...
Hi Rafael,
I did not program in Java (want to learn it right now), but I think you
should
* declare num4 _before_ using it
* pass num4 as argument to putInt
//Adds num1, num2 and num3 together.
int num4 = num1 + num2 + num3;
//puts total
jTextField4.putInt(num4);
-- Peter Pein, Berlin petsie@arcAND.de replace && by || to write to me
- Next message: Thomas Weidenfeller: "comp.lang.java.gui FAQ"
- Previous message: Andrew Thompson: "Re: GridBagLayout: can not make a component bigger"
- In reply to: Rafael: "PLEASE HELP:Calculator: I need help building a swing calculator."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]