Monday, December 8, 2008

Why Do Cats Play Apttycake?



CALCULATOR

import java.awt .*;
import javax.swing .*;
import java.awt.event .*;
Finestra2 implements ActionListener {public class
JLabel l1 = new JLabel ("First number ");
JLabel l2 = new JLabel (" second issue ");
JTextField t1 = new JTextField ();
JTextField t2 = new JTextField ();
JButton b1 = new JButton JTextField result ("+");
= new JTextField ();
creaForm1 public void () {JFrame
Window1 = new JFrame ("window IVL");
finestra1.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
finestra1.setSize (300.300);
finestra1.setLayout (new GridLayout (3,2));
finestra1.add (l1);
finestra1.add (t1);
Window1 . add (l2);
finestra1.add (t2);
finestra1.add (b1);
finestra1.add (result);
b1.addActionListener (this);
finestra1.setVisible (true);}

public void actionPerformed (ActionEvent event) {String text1 =
t1.getText ();
t2.getText String testo2 = ();
int a = Integer.parseInt (text1);
int b = Integer.parseInt (text2);
int sum = a + b;
String r = Integer.toString (sum);
risultato.setText (r);}

}

the operation of the sum is done by clicking on the "+" using the applet!

0 comments:

Post a Comment