buatlah program kalkulator seperti berikut :

lengkapi kode program berikut :

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Kalkulator011 extends JFrame implements ActionListener
{
	private JPanel 	pKalkulator       = new JPanel();

	private JTextField 	fLayar	   = new JTextField (); 

	private JButton 	btnTambah     = new JButton ("+"), 
				btnKurang	  = new JButton ("-"), 
				btn1  = new JButton ("1"), 
				btn2  = new JButton ("2"), 
				btn3  = new JButton ("3"), 
				btnSama  = new JButton ();
	
	private String isiLayar = "";
	private String snilai1, snilai2, tombol;
	private int hasil;

	public Kalkulator011() {
		setPreferredSize(new Dimension(500,600));
		setTitle("Kalkulator");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		new BorderLayout();
		JDesktopPane pKalkulator = new JDesktopPane();
		add(pKalkulator, BorderLayout.CENTER);

		/* Mengatur letak objek Text Di Container */
		fLayar.setBounds (50, 90, 385, 50);

		/* Mengatur letak objek Button di Container */
		btnTambah.setBounds (350, 160, 85, 50);	
		btnKurang.setBounds (350, 230, 85, 50);	

		btnSama.setBounds (250, 230, 85, 50);	
		btnSama.setLabel("=");									

		//btnAdd.setToolTipText("Tombol Tambah Data");
		btn1.setBounds (50, 160, 85, 50);
		btn2.setBounds (150, 160, 85, 50);
		btn3.setBounds (250, 160, 85, 50);
		
		fLayar.setHorizontalAlignment (JTextField.RIGHT);

		/* Objek Button di Non Aktifkan dan di aktifkan */
		btnTambah.setEnabled(true);		

		/* Mengatur objek untuk dapat berinteraksi */
		btn1.addActionListener (this);
		btn2.addActionListener (this);
		btn3.addActionListener (this);

		btnTambah.addActionListener (this);
		btnSama.addActionListener (this);

		// Meletakkan seluruh kontrol pada objek panel */
		pKalkulator.add (fLayar);
		pKalkulator.add (btn1);
		pKalkulator.add (btn2);
		pKalkulator.add (btn3);

		pKalkulator.add (btnTambah);		
		pKalkulator.add (btnSama);

		/* Menambahkan objek panel (pKalkulator) ke container frame */
		getContentPane().add (pKalkulator);
		
		/* Menampilkan frame ke layar monitor */
		pack();
		setVisible (true);
	
	}
	
	public static void main(String[] args) {
		new Kalkulator011().setVisible(true);
	}

	/* Fungsi jika user melakukan action penekanan tombol Button */
	public void actionPerformed (ActionEvent ae) {
		Object obj = ae.getSource();

		if (obj == btn1) 	
			{ 
			 	isiLayar = isiLayar + "1";
			 	fLayar.setText(isiLayar); 
			}
		if (obj == btn2) 	
			{ 
			 	isiLayar = isiLayar + "2";
			 	fLayar.setText(isiLayar); 
			}
		if (obj == btn3) 	
			{ 
			 	int pj = isiLayar.length();
			 	isiLayar = isiLayar.substring(0, (pj-1));
			 	fLayar.setText(isiLayar); 
			}			
			
		if (obj == btnTambah) 	
			{ 
				tombol = "tambah";
				snilai1 = fLayar.getText();
				isiLayar = "";
			 	fLayar.setText(isiLayar); 

			}				
		if (obj == btnKurang) 	
			{ 
	
			}
		if (obj == btnSama) 	
			{ 
				snilai2 = fLayar.getText();
				hasil = Integer.parseInt(snilai1) + Integer.parseInt(snilai2);
				String shasil = ""+hasil;
				fLayar.setText(shasil);
	
			}			
			
	}

	// Fungsi untuk mengkosongkan Objek masukan 
	void Kosong () 
	{
		 fLayar.setText ("");
		 fLayar.requestFocus ();
	}
}