1.

Janav Raj is programmer at Path Educo Enterprises. He created the following GUI in NetBeans. HeIp him to write code for the following :(i) To display series of odd or even numbers (depending on Starting Number - jTextField1 is even or odd) in the jTextArea on the click of command button [Display the Series]. For example: If the start number is 5 and last number is 11 TextArea content will be 57911 If the start number is 2 and last number is 10 TextArea content will be 246810 (ii) To clear both the text fields and text area, on clicking [reset button.] (iii) To terminate the application on the click [Stop button]. (assume suitable name for the various controls on the form)

Answer»

(i) int s = Integer.parseInt(jTextField1.getText().trim());

int e = Integer.parseInt(TextField2.getText().trim());

while (s <= e)

{

jTextArea1.append(" " + s +" ");

S+ = 2;

}

(ii) jTextField1.setText(" ");

jTextField2.setText(" ") ;

jTextField3.setText(" ");

(iii) System.exit (0);

System.exit ( );



Discussion

No Comment Found