Dear All

I am tring to do 1 simple job but some where I am missing something
I designed 1 GUI in Netbeans 3 jTextFields, 2 jButtons (design attached)

Step 1-> Input any number in 1st text field 2
Step 2-> Input any number in 2nd text field 2
Step 3-> Click on Add button and sum of both the entered number should be displayed in 3rd Box 4
Step 4-> Change the 1st Text Field number ONLY 3
Step 5-> Again do the addition by clicking same Add Button 5
Step 6-> Now multiply the both sumed up no and display in the 3rd box 20

Attachments design.JPG 8.45 KB

Have you done any code for the models or controllers?

Hi White Feather

Thanx for considering my post

Yes a small code for both the jButtons

int v1;
int v2;
int v3;
int v4;
int v5;
int v;
    private void b1ActionPerformed(java.awt.event.ActionEvent evt) {                                   

v1=Integer.parseInt(t1.getText());
v2=Integer.parseInt(t2.getText());
v3=v1+v2;
t3.setText(Integer.toString(v3));
v4=v1+v2;
t3.setText(Integer.toString(v3));
v=v3;
    }                                  

    private void b2ActionPerformed(java.awt.event.ActionEvent evt) {                                   
v5=v*v4;
t4.setText(Integer.toString(v5));    
    }

first off you'll want to catch a parsing error for the text in the text fields
And do the steps always need to be the same way?

first off you'll want to catch a parsing error for the text in the text fields
And do the steps always need to be the same way?

Can't understand waht you want to say

Are the steps you listed (1-6) must be followed. For example: if the user the multiplication first, will it throw an error?

Hi White Feather

Yes I have to follow all the Six steps as mentioned and if I do multiplication first it will not throw any exception. But without any value if I add there I will get exception.
But that is not my problem problem is I am not getting correct output.

This article has been dead for over six months. Start a new discussion instead.