//Program Kalkulator Dengan GUI
import java.awt.*;
public class kalkulator_GUI {
private Frame program_GUI;
private TextField masukan;
private Button MC, MR, MS, Mplus, Mmins, panah , CE, C, plusminus, a,tujuh, delapan, sembilan, bagi, persen, empat, lima, enam,
kali, satubagix, satu, dua, tiga, kurang, smDengan, nol, koma, tambah;
public kalkulator_GUI() {
program_GUI=new Frame("kalkulator"); //menampilkan judul masukan =new TextField ("0 ");
MC =new Button ("MC");
MR =new Button ("MR");
MS =new Button ("MS");
Mplus =new Button ("M+");
Mmins =new Button ("M- ");
panah =new Button ("<-- ");
CE =new Button ("CE ");
C =new Button (" C ");
plusminus =new Button (" -/+");
a =new Button (" ^ ");
tujuh =new Button (" 7 ");
delapan =new Button (" 8 ");
sembilan =new Button (" 9 ");
bagi =new Button (" / ");
persen =new Button (" % ");
empat =new Button (" 4 ");
lima =new Button (" 5 ");
enam =new Button (" 6 ");
kali =new Button (" * ");
satubagix =new Button ("1/x ");
satu =new Button (" 1 ");
dua =new Button (" 2 ");
tiga =new Button (" 3 ");
kurang =new Button (" - ");
smDengan =new Button (" = ");
nol =new Button (" 0 ");
koma =new Button (" , ");
tambah =new Button (" + ");
}
/**
*
* http://www.kaptenteknologi.com ( Rifki Bachmid )
*/
*
* http://www.kaptenteknologi.com ( Rifki Bachmid )
*/
public void kalkulator() {
program_GUI.setLayout(new FlowLayout(FlowLayout.RIGHT));
program_GUI.add (masukan);
program_GUI.add(MC, BorderLayout.WEST);
program_GUI.add(MR, BorderLayout.WEST);
program_GUI.add(MS, BorderLayout.WEST);
program_GUI.add(Mplus, BorderLayout.WEST);
program_GUI.add(Mmins, BorderLayout.WEST);
program_GUI.add(panah, BorderLayout.WEST);
program_GUI.add(CE, BorderLayout.WEST);
program_GUI.add(C, BorderLayout.WEST);
program_GUI.add(plusminus, BorderLayout.WEST);
program_GUI.add(a, BorderLayout.WEST);
program_GUI.add(tujuh, BorderLayout.WEST);
program_GUI.add(delapan, BorderLayout.WEST);
program_GUI.add(sembilan, BorderLayout.WEST);
program_GUI.add(bagi, BorderLayout.WEST);
program_GUI.add(persen, BorderLayout.WEST);
program_GUI.add(empat, BorderLayout.WEST);
program_GUI.add(lima, BorderLayout.WEST);
program_GUI.add(enam, BorderLayout.WEST);
program_GUI.add(kali, BorderLayout.WEST);
program_GUI.add(satubagix, BorderLayout.WEST);
program_GUI.add(satu, BorderLayout.WEST);
program_GUI.add(dua, BorderLayout.WEST);
program_GUI.add(tiga, BorderLayout.WEST);
program_GUI.add(kurang, BorderLayout.WEST);
program_GUI.add(smDengan, BorderLayout.WEST);
program_GUI.add(nol, BorderLayout.WEST);
program_GUI.add(koma, BorderLayout.WEST);
program_GUI.add(tambah, BorderLayout.WEST);
program_GUI.pack();
program_GUI.setVisible(true);
program_GUI.setResizable(false);
program_GUI.setSize(200,250); //set ukuran panjang lebarprogram_GUI.setBackground(Color.blue); //set ukuran untuk warna backgroud
}
public static void main(String args[]) {
kalkulator_GUI guiWindow = new kalkulator_GUI(); // samakan dengan nama class yang anda buat
guiWindow.kalkulator();
}
}
Output
keren sobat infonya...
BalasHapusbisa lebih efisien neh
waaaaaaaaaaah patut di coba nih bang,hahaha
BalasHapuslangsung di praktekin akh.....
yang ini nih yang keren mah sob!! :)
BalasHapusahli java...
BalasHapuskalo yang pake .NET ada g??