0

Top of the day to you guys out there! Kindly assist in this program.It's made up of six textfields and a button on a panel.it should work in such a way that the fifth textfield displays the sum of the values entered into the first four on pressing the button.Also,the display of the sixth textfield should be dependent on the value returned by the fifth at the press of the button.

Thanks a trillion,
Bobinson

2
Contributors
2
Replies
3
Views
13 Years
Discussion Span
Last Post by bobinson
0

Lets give it a try :

Button.addActionListener( new java.awt.event.ActionListener(){
public void actionPerformed(ActionEvent e){

//convert fields into integers
int a = Integer.ParseInt(TextField1);
int b = Integer.ParseInt(TextField2);
int c = Integer.ParseInt(TextField3);
int d = Integer.ParseInt(TextField4);

//adding all numbers
int e = a + b + c + d;

//displaying the result in TextField5
TextField.setText(""+e);
}
});

This sample code will help you .... build the app now.

0

Dear Nanosani,
Peace of the LORD be yours,thanks a trillion for that rescue,The code snippets you provided work perfectly well.

Take very good care of yourself and keep enjoying.

Yours,
Bobinson.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.