* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package praktikum;
import javax.swing.JFrame;
/**
*
* @author Dhewan
*/
public class kalkulator extends javax.swing.JFrame {
String angka0 = "";
Double angka1,angka2,total;
int pilih;
/**
* Creates new form kalkulator
*/
public kalkulator() {
initComponents();
angka0 = "";
angka.setHorizontalAlignment(angka.RIGHT);
}
String operasi="des",operasi1="";
void bingung(){
try{
String mon = angka.getText();
if(operasi.equalsIgnoreCase("bin")&& operasi1.equalsIgnoreCase("des")){
angka.setText(""+Integer.parseInt(mon,2));
operasi="des";
}
else if(operasi.equalsIgnoreCase("bin")&& operasi1.equalsIgnoreCase("okt")){
int a=Integer.parseInt(mon,2);
angka.setText(""+Integer.toOctalString(a));
operasi="okt";
}
else if(operasi.equalsIgnoreCase("bin")&& operasi1.equalsIgnoreCase("hex")){
int a=Integer.parseInt(mon,2);
angka.setText(""+Integer.toHexString(a));
operasi="hex";
}
else if(operasi.equalsIgnoreCase("okt")&& operasi1.equalsIgnoreCase("des")){
int a=Integer.parseInt(mon,8);
angka.setText(""+a);
operasi="des";
}
else if(operasi.equalsIgnoreCase("okt")&& operasi1.equalsIgnoreCase("bin")){
int a=Integer.parseInt(mon,8);
angka.setText(""+Integer.toBinaryString(a));
operasi="bin";
}
else if(operasi.equalsIgnoreCase("okt")&& operasi1.equalsIgnoreCase("hex")){
int a=Integer.parseInt(mon,8);
angka.setText(""+Integer.toHexString(a));
operasi="hex";
}
else if(operasi.equalsIgnoreCase("hex")&& operasi1.equalsIgnoreCase("des")){
int a=Integer.parseInt(mon,16);
angka.setText(""+a);
operasi="des";
}
else if(operasi.equalsIgnoreCase("hex")&& operasi1.equalsIgnoreCase("bin")){
int a=Integer.parseInt(mon,16);
angka.setText(""+Integer.toBinaryString(a));
operasi="bin";
}
else if(operasi.equalsIgnoreCase("hex")&& operasi1.equalsIgnoreCase("okt")){
int a=Integer.parseInt(mon,16);
angka.setText(""+Integer.toOctalString(a));
operasi="okt";
}
else if(operasi.equalsIgnoreCase("des")&& operasi1.equalsIgnoreCase("bin")){
angka.setText(""+Integer.toBinaryString(Integer.parseInt(mon)));
operasi="bin";
}
else if(operasi.equalsIgnoreCase("des")&& operasi1.equalsIgnoreCase("okt")){
angka.setText(""+Integer.toOctalString(Integer.parseInt(mon)));
operasi="okt";
}
else if(operasi.equalsIgnoreCase("des")&& operasi1.equalsIgnoreCase("hex")){
angka.setText(""+Integer.toHexString(Integer.parseInt(mon)));
operasi="hex";
}
}catch(NumberFormatException ab){
angka.setText("error");
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
angka = new javax.swing.JTextField();
tujuh = new javax.swing.JButton();
empat = new javax.swing.JButton();
satu = new javax.swing.JButton();
delapan = new javax.swing.JButton();
lima = new javax.swing.JButton();
dua = new javax.swing.JButton();
sembilan = new javax.swing.JButton();
enam = new javax.swing.JButton();
tiga = new javax.swing.JButton();
nol = new javax.swing.JButton();
jButton11 = new javax.swing.JButton();
titik = new javax.swing.JButton();
bagi = new javax.swing.JButton();
kali = new javax.swing.JButton();
minus = new javax.swing.JButton();
tambah = new javax.swing.JButton();
sama = new javax.swing.JButton();
hapus = new javax.swing.JButton();
jRadioButton1 = new javax.swing.JRadioButton();
jRadioButton2 = new javax.swing.JRadioButton();
jRadioButton3 = new javax.swing.JRadioButton();
jRadioButton4 = new javax.swing.JRadioButton();
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Itung-Itungan");
setAlwaysOnTop(true);
setBackground(new java.awt.Color(255, 200, 0));
angka.setText("0");
angka.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
angka.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
angkaActionPerformed(evt);
}
});
tujuh.setBackground(java.awt.Color.red);
tujuh.setText("7");
tujuh.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tujuhActionPerformed(evt);
}
});
empat.setBackground(java.awt.Color.red);
empat.setText("4");
empat.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
empatActionPerformed(evt);
}
});
satu.setBackground(java.awt.Color.red);
satu.setText("1");
satu.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
satuActionPerformed(evt);
}
});
delapan.setBackground(java.awt.Color.red);
delapan.setText("8");
delapan.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
delapanActionPerformed(evt);
}
});
lima.setBackground(java.awt.Color.red);
lima.setText("5");
lima.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
limaActionPerformed(evt);
}
});
dua.setBackground(java.awt.Color.red);
dua.setText("2");
dua.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
duaActionPerformed(evt);
}
});
sembilan.setBackground(java.awt.Color.red);
sembilan.setText("9");
sembilan.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
sembilanActionPerformed(evt);
}
});
enam.setBackground(java.awt.Color.red);
enam.setText("6");
enam.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
enamActionPerformed(evt);
}
});
tiga.setBackground(java.awt.Color.red);
tiga.setText("3");
tiga.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tigaActionPerformed(evt);
}
});
nol.setBackground(java.awt.Color.red);
nol.setText("0");
nol.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
nolActionPerformed(evt);
}
});
jButton11.setBackground(java.awt.Color.red);
jButton11.setText("00");
jButton11.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton11ActionPerformed(evt);
}
});
titik.setBackground(java.awt.Color.red);
titik.setText(".");
titik.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
titikActionPerformed(evt);
}
});
bagi.setBackground(java.awt.Color.red);
bagi.setText("/");
bagi.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bagiActionPerformed(evt);
}
});
kali.setBackground(java.awt.Color.red);
kali.setText("X");
kali.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
kaliActionPerformed(evt);
}
});
minus.setBackground(java.awt.Color.red);
minus.setText("-");
minus.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
minusActionPerformed(evt);
}
});
tambah.setBackground(java.awt.Color.red);
tambah.setText("+");
tambah.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tambahActionPerformed(evt);
}
});
sama.setBackground(java.awt.Color.red);
sama.setForeground(new java.awt.Color(255, 102, 102));
sama.setText("=");
sama.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
samaActionPerformed(evt);
}
});
hapus.setBackground(java.awt.Color.red);
hapus.setForeground(new java.awt.Color(51, 51, 51));
hapus.setText("clr");
hapus.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
hapusActionPerformed(evt);
}
});
buttonGroup1.add(jRadioButton1);
jRadioButton1.setText("Dec");
jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton1ActionPerformed(evt);
}
});
buttonGroup1.add(jRadioButton2);
jRadioButton2.setText("Hex");
jRadioButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton2ActionPerformed(evt);
}
});
buttonGroup1.add(jRadioButton3);
jRadioButton3.setText("Bin");
jRadioButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton3ActionPerformed(evt);
}
});
buttonGroup1.add(jRadioButton4);
jRadioButton4.setText("Oct");
jRadioButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButton4ActionPerformed(evt);
}
});
jButton1.setBackground(new java.awt.Color(255, 0, 0));
jButton1.setText("%");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(angka, javax.swing.GroupLayout.PREFERRED_SIZE, 321, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(34, 34, 34))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(tujuh, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(delapan, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(empat, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(lima, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(satu, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(dua, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(0, 1, Short.MAX_VALUE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(sembilan, javax.swing.GroupLayout.DEFAULT_SIZE, 51, Short.MAX_VALUE)
.addComponent(tiga, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(enam, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(nol, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(titik, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jRadioButton1)
.addGap(41, 41, 41)
.addComponent(jRadioButton3)))
.addGap(0, 0, Short.MAX_VALUE)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jRadioButton2)
.addGap(44, 44, 44)
.addComponent(jRadioButton4)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 44, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(sama, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(bagi, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(tambah, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 52, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(minus, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(hapus, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(kali, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGap(93, 93, 93))))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(angka, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jRadioButton1)
.addComponent(jRadioButton3)
.addComponent(jRadioButton4)
.addComponent(jRadioButton2))
.addGap(21, 21, 21)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(delapan, javax.swing.GroupLayout.DEFAULT_SIZE, 51, Short.MAX_VALUE)
.addComponent(hapus, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(tujuh, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(sembilan, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(26, 26, 26)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lima, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(bagi, javax.swing.GroupLayout.DEFAULT_SIZE, 51, Short.MAX_VALUE)
.addComponent(kali, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(enam, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(empat, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(25, 25, 25)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(tiga, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(dua, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(satu, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(tambah, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(minus, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(28, 28, 28)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(sama, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(titik, javax.swing.GroupLayout.DEFAULT_SIZE, 43, Short.MAX_VALUE)
.addComponent(nol, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(34, 34, 34))
);
pack();
}// </editor-fold>
private void satuActionPerformed(java.awt.event.ActionEvent evt) {
angka0 += "1";
angka.setText(angka0);
}
private void duaActionPerformed(java.awt.event.ActionEvent evt) {
angka0 += "2";
angka.setText(angka0);
}
private void tigaActionPerformed(java.awt.event.ActionEvent evt) {
angka0 += "3";
angka.setText(angka0);
}
private void empatActionPerformed(java.awt.event.ActionEvent evt) {
angka0 += "4";
angka.setText(angka0);
}
private void limaActionPerformed(java.awt.event.ActionEvent evt) {
angka0 += "5";
angka.setText(angka0);
}
private void enamActionPerformed(java.awt.event.ActionEvent evt) {
angka0 += "6";
angka.setText(angka0);
}
private void tujuhActionPerformed(java.awt.event.ActionEvent evt) {
angka0 += "7";
angka.setText(angka0);
}
private void delapanActionPerformed(java.awt.event.ActionEvent evt) {
angka0 += "8";
angka.setText(angka0);
}
private void sembilanActionPerformed(java.awt.event.ActionEvent evt) {
angka0 += "9";
angka.setText(angka0);
}
private void nolActionPerformed(java.awt.event.ActionEvent evt) {
angka0 += "0";
angka.setText(angka0);
}
private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {
angka0 +="00";
angka.setText("00");
}
private void titikActionPerformed(java.awt.event.ActionEvent evt) {
angka0 +=".";
angka.setText(".");
}
private void tambahActionPerformed(java.awt.event.ActionEvent evt) {
angka1=Double.parseDouble(angka0);
//txtLayar.setText("+");
angka0="";
pilih=1;
}
private void minusActionPerformed(java.awt.event.ActionEvent evt) {
angka1 = Double.parseDouble(angka0);
//angka.setText("-");
angka0="";
pilih=2;
}
private void kaliActionPerformed(java.awt.event.ActionEvent evt) {
angka1=Double.parseDouble(angka0);
//angka.setText("*");
angka0="";
pilih=3;
}
private void bagiActionPerformed(java.awt.event.ActionEvent evt) {
angka1=Double.parseDouble(angka0);
//txtLayar.setText("/");
angka0="";
pilih=4;
}
private void hapusActionPerformed(java.awt.event.ActionEvent evt) {
angka0 = "";
angka.setText("0");
}
private void samaActionPerformed(java.awt.event.ActionEvent evt) {
switch(pilih){
case 1:
angka2=Double.parseDouble(angka0);
total=angka1+angka2;
angka0=Double.toString(total);
angka.setText(angka0);
break;
case 2:
angka2 = Double.parseDouble(angka0);
total = angka1 - angka2;
angka0 = Double.toString(total);
angka.setText(angka0);
break;
case 3:
angka2 = Double.parseDouble(angka0);
total = angka1 * angka2;
angka0 = Double.toString(total);
angka.setText(angka0);
break;
case 4:
angka2 = Double.parseDouble(angka0);
total = angka1 / angka2;
angka0 = Double.toString(total);
angka.setText(angka0);
default:
break;
}
}
private void angkaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {
titik.setEnabled(true);
tiga.setEnabled(true);
empat.setEnabled(true);
dua.setEnabled(true);
lima.setEnabled(true);
enam.setEnabled(true);
tujuh.setEnabled(true);
delapan.setEnabled(true);
sembilan.setEnabled(true);
satu.setEnabled(true);
nol.setEnabled(true);
operasi1="des";
bingung();
}
private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {
titik.setEnabled(false);
satu.setEnabled(true);
nol.setEnabled(true);
tiga.setEnabled(true);
empat.setEnabled(true);
dua.setEnabled(true);
lima.setEnabled(true);
enam.setEnabled(true);
tujuh.setEnabled(true);
delapan.setEnabled(true);
sembilan.setEnabled(true);
operasi1="hex";
bingung();
}
private void jRadioButton4ActionPerformed(java.awt.event.ActionEvent evt) {
titik.setEnabled(false);
satu.setEnabled(true);
nol.setEnabled(true);
tiga.setEnabled(true);
empat.setEnabled(true);
dua.setEnabled(true);
lima.setEnabled(true);
enam.setEnabled(true);
tujuh.setEnabled(true);
delapan.setEnabled(false);
sembilan.setEnabled(false);
operasi1="okt";
bingung();
}
private void jRadioButton3ActionPerformed(java.awt.event.ActionEvent evt) {
titik.setEnabled(false);
satu.setEnabled(true);
nol.setEnabled(true);
tiga.setEnabled(false);
empat.setEnabled(false);
dua.setEnabled(false);
lima.setEnabled(false);
enam.setEnabled(false);
tujuh.setEnabled(false);
delapan.setEnabled(false);
sembilan.setEnabled(false);
operasi1="bin";
bingung();
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(kalkulator.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(kalkulator.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(kalkulator.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(kalkulator.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new kalkulator().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JTextField angka;
private javax.swing.JButton bagi;
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JButton delapan;
private javax.swing.JButton dua;
private javax.swing.JButton empat;
private javax.swing.JButton enam;
private javax.swing.JButton hapus;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton11;
private javax.swing.JRadioButton jRadioButton1;
private javax.swing.JRadioButton jRadioButton2;
private javax.swing.JRadioButton jRadioButton3;
private javax.swing.JRadioButton jRadioButton4;
private javax.swing.JButton kali;
private javax.swing.JButton lima;
private javax.swing.JButton minus;
private javax.swing.JButton nol;
private javax.swing.JButton sama;
private javax.swing.JButton satu;
private javax.swing.JButton sembilan;
private javax.swing.JButton tambah;
private javax.swing.JButton tiga;
private javax.swing.JButton titik;
private javax.swing.JButton tujuh;
// End of variables declaration
}
Nama : Mochammad Rian Dhewantara
Nim : 2012420093
Fakultas : Teknik Informatika
UNITOMO
Posted by 01.08 and have
0
komentar
, Published at
Tidak ada komentar:
Posting Komentar