public class kalkulator1 extends javax.swing.JFrame {
static double angka1 =0, angka2=0;
static int pilihan=0;
boolean plus,minus,kali,bagi,mod;
/** Creates new form kalkulator1 */
public kalkulator1() {
initComponents();
setTitle("kalkulator' 2012420130");
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
jPanel1 = new javax.swing.JPanel();
jRadioButtondesimal = new javax.swing.JRadioButton();
jRadioButtonhexa = new javax.swing.JRadioButton();
jRadioButtonbiner = new javax.swing.JRadioButton();
jRadioButtonoktal = new javax.swing.JRadioButton();
jPanel2 = new javax.swing.JPanel();
jTextField1 = new javax.swing.JTextField();
jPanel3 = new javax.swing.JPanel();
jButtontambah = new javax.swing.JButton();
jButtonmin = new javax.swing.JButton();
jButtonbagi = new javax.swing.JButton();
jButtonkali = new javax.swing.JButton();
jButtontitik = new javax.swing.JButton();
jButtonmod = new javax.swing.JButton();
jButtonsmdgn = new javax.swing.JButton();
jButtonc = new javax.swing.JButton();
jButtonC = new javax.swing.JButton();
jButtonB = new javax.swing.JButton();
jButton9 = new javax.swing.JButton();
jButtonA = new javax.swing.JButton();
jButton1 = new javax.swing.JButton();
jButton7 = new javax.swing.JButton();
jButton6 = new javax.swing.JButton();
jButton8 = new javax.swing.JButton();
jButton0 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButtonF = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
jButtonE = new javax.swing.JButton();
jButtonD = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.TRAILING, javax.swing.border.TitledBorder.TOP));
buttonGroup1.add(jRadioButtondesimal);
jRadioButtondesimal.setText("desimal");
jRadioButtondesimal.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jRadioButtondesimalMouseClicked(evt);
}
});
jRadioButtondesimal.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButtondesimalActionPerformed(evt);
}
});
buttonGroup1.add(jRadioButtonhexa);
jRadioButtonhexa.setText("hexa");
jRadioButtonhexa.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButtonhexaActionPerformed(evt);
}
});
buttonGroup1.add(jRadioButtonbiner);
jRadioButtonbiner.setText("biner");
jRadioButtonbiner.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButtonbinerActionPerformed(evt);
}
});
buttonGroup1.add(jRadioButtonoktal);
jRadioButtonoktal.setText("oktal");
jRadioButtonoktal.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jRadioButtonoktalActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jRadioButtonbiner)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jRadioButtonoktal)
.addGap(18, 18, 18)
.addComponent(jRadioButtondesimal)
.addGap(27, 27, 27)
.addComponent(jRadioButtonhexa)
.addGap(46, 46, 46))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jRadioButtonbiner)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jRadioButtonoktal)
.addComponent(jRadioButtonhexa)
.addComponent(jRadioButtondesimal)))
.addContainerGap(30, Short.MAX_VALUE))
);
jPanel2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
jTextField1.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
jTextField1.setAutoscrolls(false);
jTextField1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTextField1ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 365, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.TRAILING, javax.swing.border.TitledBorder.TOP));
jButtontambah.setText("+");
jButtontambah.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtontambahActionPerformed(evt);
}
});
jButtonmin.setText("-");
jButtonmin.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonminActionPerformed(evt);
}
});
jButtonbagi.setText(":");
jButtonbagi.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonbagiActionPerformed(evt);
}
});
jButtonkali.setText("x");
jButtonkali.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonkaliActionPerformed(evt);
}
});
jButtontitik.setText(".");
jButtontitik.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtontitikActionPerformed(evt);
}
});
jButtonmod.setText("mod");
jButtonmod.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonmodActionPerformed(evt);
}
});
jButtonsmdgn.setText("=");
jButtonsmdgn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonsmdgnActionPerformed(evt);
}
});
jButtonc.setText("c");
jButtonc.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtoncActionPerformed(evt);
}
});
jButtonC.setText("C");
jButtonC.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonCActionPerformed(evt);
}
});
jButtonB.setText("B");
jButtonB.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonBActionPerformed(evt);
}
});
jButton9.setText("9");
jButton9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton9ActionPerformed(evt);
}
});
jButtonA.setText("A");
jButtonA.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonAActionPerformed(evt);
}
});
jButton1.setText("1");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton7.setText("7");
jButton7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton7ActionPerformed(evt);
}
});
jButton6.setText("6");
jButton6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton6ActionPerformed(evt);
}
});
jButton8.setText("8");
jButton8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton8ActionPerformed(evt);
}
});
jButton0.setText("0");
jButton0.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton0ActionPerformed(evt);
}
});
jButton3.setText("3");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jButtonF.setText("F");
jButtonF.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonFActionPerformed(evt);
}
});
jButton2.setText("2");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton5.setText("5");
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});
jButtonE.setText("E");
jButtonE.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonEActionPerformed(evt);
}
});
jButtonD.setText("D");
jButtonD.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButtonDActionPerformed(evt);
}
});
jButton4.setText("4");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButtonD, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButtonA, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton7, javax.swing.GroupLayout.Alignment.LEADING))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton8, javax.swing.GroupLayout.DEFAULT_SIZE, 45, Short.MAX_VALUE)
.addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, 45, Short.MAX_VALUE)
.addComponent(jButtonE, javax.swing.GroupLayout.DEFAULT_SIZE, 45, Short.MAX_VALUE)
.addComponent(jButtonB, javax.swing.GroupLayout.DEFAULT_SIZE, 45, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 45, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton9)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jButtonC, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButtonF, javax.swing.GroupLayout.Alignment.LEADING))
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jButton6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton3, javax.swing.GroupLayout.Alignment.LEADING))))
.addComponent(jButton0, javax.swing.GroupLayout.DEFAULT_SIZE, 135, Short.MAX_VALUE))
.addGap(18, 18, 18)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jButtontambah, javax.swing.GroupLayout.DEFAULT_SIZE, 56, Short.MAX_VALUE)
.addComponent(jButtontitik, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 56, Short.MAX_VALUE)
.addComponent(jButtonbagi, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 56, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButtonmin, javax.swing.GroupLayout.DEFAULT_SIZE, 56, Short.MAX_VALUE)
.addComponent(jButtonkali, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 56, Short.MAX_VALUE)
.addComponent(jButtonmod, javax.swing.GroupLayout.Alignment.TRAILING)))
.addComponent(jButtonsmdgn, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
.addComponent(jButtonc, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE))
.addContainerGap())
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButtonmin)
.addComponent(jButtontambah))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButtonbagi)
.addComponent(jButtonkali))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jButtonmod, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButtontitik, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButtonsmdgn)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButtonc, javax.swing.GroupLayout.DEFAULT_SIZE, 48, Short.MAX_VALUE)
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButtonA)
.addComponent(jButtonC)
.addComponent(jButtonB))
.addGap(7, 7, 7)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButtonD, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButtonF)
.addComponent(jButtonE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(7, 7, 7)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton2)
.addComponent(jButton1)
.addComponent(jButton3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton4)
.addComponent(jButton5)
.addComponent(jButton6))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton7)
.addComponent(jButton8)
.addComponent(jButton9))
.addGap(11, 11, 11)
.addComponent(jButton0))))
);
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(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(24, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 19, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18))
);
pack();
}// </editor-fold>
private void jRadioButtondesimalMouseClicked(java.awt.event.MouseEvent evt) {
}
private void jRadioButtondesimalActionPerformed(java.awt.event.ActionEvent evt) {
jButtonA.setEnabled(false);
jButtonB.setEnabled(false);
jButtonC.setEnabled(false);
jButtonD.setEnabled(false);
jButtonE.setEnabled(false);
jButtonF.setEnabled(false);
jButton1.setEnabled(true);
jButton2.setEnabled(true);
jButton3.setEnabled(true);
jButton4.setEnabled(true);
jButton5.setEnabled(true);
jButton6.setEnabled(true);
jButton7.setEnabled(true);
jButton8.setEnabled(true);
jButton9.setEnabled(true);
jButton0.setEnabled(true);
jButtontitik.setEnabled(true);
String a = jTextField1.getText();
int x = Integer.parseInt(a,10);
jTextField1.setText(Integer.toBinaryString(x));
}
private void jRadioButtonbinerActionPerformed(java.awt.event.ActionEvent evt) {
jButton2.setEnabled(false);
jButton3.setEnabled(false);
jButton4.setEnabled(false);
jButton5.setEnabled(false);
jButton6.setEnabled(false);
jButton7.setEnabled(false);
jButton8.setEnabled(false);
jButton9.setEnabled(false);
jButtonA.setEnabled(false);
jButtonB.setEnabled(false);
jButtonC.setEnabled(false);
jButtonD.setEnabled(false);
jButtonE.setEnabled(false);
jButtonF.setEnabled(false);
jButton1.setEnabled(true);
jButton0.setEnabled(true);
jButtontitik.setEnabled(false);
String a = jTextField1.getText();
int x = Integer.parseInt(a,20);
jTextField1.setText(Integer.toBinaryString(x));
}
private void jRadioButtonoktalActionPerformed(java.awt.event.ActionEvent evt) {
jButtontitik.setEnabled(false);
jButton8.setEnabled(false);
jButton9.setEnabled(false);
jButtonA.setEnabled(false);
jButtonB.setEnabled(false);
jButtonC.setEnabled(false);
jButtonD.setEnabled(false);
jButtonE.setEnabled(false);
jButtonF.setEnabled(false);
jButton1.setEnabled(true);
jButton0.setEnabled(true);
jButton2.setEnabled(true);
jButton3.setEnabled(true);
jButton4.setEnabled(true);
jButton5.setEnabled(true);
jButton6.setEnabled(true);
jButton7.setEnabled(true);
String a = jTextField1.getText();
int x = Integer.parseInt(a,80);
jTextField1.setText(Integer.toBinaryString(x));
}
private void jRadioButtonhexaActionPerformed(java.awt.event.ActionEvent evt) {
jButton1.setEnabled(true);
jButton2.setEnabled(true);
jButton3.setEnabled(true);
jButton4.setEnabled(true);
jButton5.setEnabled(true);
jButton6.setEnabled(true);
jButton7.setEnabled(true);
jButton8.setEnabled(true);
jButton9.setEnabled(true);
jButton0.setEnabled(true);
jButtonA.setEnabled(true);
jButtonB.setEnabled(true);
jButtonC.setEnabled(true);
jButtonD.setEnabled(true);
jButtonE.setEnabled(true);
jButtonF.setEnabled(true);
jButtontitik.setEnabled(true);
String a = jTextField1.getText();
int x = Integer.parseInt(a,160);
jTextField1.setText(Integer.toBinaryString(x));
}
private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void jButtoncActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText("");
}
private void jButtonsmdgnActionPerformed(java.awt.event.ActionEvent evt) {
switch(pilihan){
case 1:
angka2=angka1;
angka1=Double.parseDouble(jTextField1.getText());
jTextField1.setText(Double.toString(angka2+angka1));
break;
case 2:
angka2=angka1;
angka1=Double.parseDouble(jTextField1.getText());
jTextField1.setText(Double.toString(angka2-angka1));
break;
case 3:
angka2=angka1;
angka1=Double.parseDouble(jTextField1.getText());
jTextField1.setText(Double.toString(angka2*angka1));
break;
case 4:
angka2=angka1;
angka1=Double.parseDouble(jTextField1.getText());
jTextField1.setText(Double.toString(angka2/angka1));
break;
case 5:
angka2=angka1;
angka1=Double.parseDouble(jTextField1.getText());
jTextField1.setText(Double.toString(angka2%angka1));
case 6:
if(plus){
angka2=angka1;
angka1=Double.parseDouble(jTextField1.getText());
jTextField1.setText(Double.toString(angka2+angka1));
}else if (minus){
angka2=angka1;
angka1=Double.parseDouble(jTextField1.getText());
jTextField1.setText(Double.toString(angka2-angka1));
}else if (kali){
angka2=angka1;
angka1=Double.parseDouble(jTextField1.getText());
jTextField1.setText(Double.toString(angka2*angka1));
} else if (bagi){
angka2=angka1;
angka1=Double.parseDouble(jTextField1.getText());
jTextField1.setText(Double.toString(angka2/angka1));
}else if (mod){
angka2=angka1;
angka1=Double.parseDouble(jTextField1.getText());
jTextField1.setText(Double.toString(angka2%angka1));
}
break;
}
}
private void jButtonmodActionPerformed(java.awt.event.ActionEvent evt) {
pilihan=5;
mod = true;
angka2=angka1;
angka1=Double.parseDouble(jTextField1.getText());
jTextField1.setText("");
}
private void jButtontitikActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(jTextField1.getText()+".");
}
private void jButtonkaliActionPerformed(java.awt.event.ActionEvent evt) {
pilihan = 3 ;
kali = true;
angka2=angka1;
angka1=Double.parseDouble(jTextField1.getText());
jTextField1.setText("");
}
private void jButtonbagiActionPerformed(java.awt.event.ActionEvent evt) {
pilihan =4;
bagi = true;
angka2=angka1;
angka1=Double.parseDouble(jTextField1.getText());
jTextField1.setText("");
}
private void jButtonminActionPerformed(java.awt.event.ActionEvent evt) {
pilihan =2 ;
minus = true;
angka2=angka1;
angka1=Double.parseDouble(jTextField1.getText());
jTextField1.setText("");
}
private void jButtontambahActionPerformed(java.awt.event.ActionEvent evt) {
pilihan=1;
plus = true;
angka2=angka1;
angka1=Double.parseDouble(jTextField1.getText());
jTextField1.setText("");
}
private void jButton0ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(jTextField1.getText()+"0");
}
private void jButtonFActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(jTextField1.getText()+"F");
}
private void jButtonEActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(jTextField1.getText()+"E");
}
private void jButtonDActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(jTextField1.getText()+"D");
}
private void jButtonBActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(jTextField1.getText()+"B");
}
private void jButtonCActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(jTextField1.getText()+"C");
}
private void jButtonAActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(jTextField1.getText()+"A");
}
private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(jTextField1.getText()+"9");
}
private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(jTextField1.getText()+"8");
}
private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(jTextField1.getText()+"7");
}
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(jTextField1.getText()+"6");
}
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(jTextField1.getText()+"5");
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(jTextField1.getText()+"4");
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(jTextField1.getText()+"3");
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(jTextField1.getText()+"2");
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
jTextField1.setText(jTextField1.getText()+"1");
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new kalkulator1().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JButton jButton0;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JButton jButton6;
private javax.swing.JButton jButton7;
private javax.swing.JButton jButton8;
private javax.swing.JButton jButton9;
private javax.swing.JButton jButtonA;
private javax.swing.JButton jButtonB;
private javax.swing.JButton jButtonC;
private javax.swing.JButton jButtonD;
private javax.swing.JButton jButtonE;
private javax.swing.JButton jButtonF;
private javax.swing.JButton jButtonbagi;
private javax.swing.JButton jButtonc;
private javax.swing.JButton jButtonkali;
private javax.swing.JButton jButtonmin;
private javax.swing.JButton jButtonmod;
private javax.swing.JButton jButtonsmdgn;
private javax.swing.JButton jButtontambah;
private javax.swing.JButton jButtontitik;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JRadioButton jRadioButtonbiner;
private javax.swing.JRadioButton jRadioButtondesimal;
private javax.swing.JRadioButton jRadioButtonhexa;
private javax.swing.JRadioButton jRadioButtonoktal;
private javax.swing.JTextField jTextField1;
// End of variables declaration
}
Posted by 22.00 and have
0
komentar
, Published at
Tidak ada komentar:
Posting Komentar