/*
* To change this template, choose
Tools | Templates
* and open the template in the editor.
*/
package seno;
import javax.swing.JFrame;
/**
*
* @author user
*/
public class kalkulatorfaisol extends
javax.swing.JFrame {
double jumlah,total,bil1;
/**
* Creates new form kalkulatorfaisol
*/
public kalkulatorfaisol() {
initComponents();
setTitle("K A L K U L A T
O R ");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
String
perhitungan="des",perhitungan1="";
public void kalk(){
try{
String coy = hasil.getText();
if(perhitungan.equalsIgnoreCase("bin")&&
perhitungan1.equalsIgnoreCase("des")){
hasil.setText(""+Integer.parseInt(coy,2));
perhitungan="des";
}
else
if(perhitungan.equalsIgnoreCase("bin")&&
perhitungan1.equalsIgnoreCase("okt")){
int a=Integer.parseInt(coy,2);
hasil.setText(""+Integer.toOctalString(a));
perhitungan="okt";
}
else
if(perhitungan.equalsIgnoreCase("bin")&&
perhitungan1.equalsIgnoreCase("hex")){
int a=Integer.parseInt(coy,2);
hasil.setText(""+Integer.toHexString(a));
perhitungan="hex";
}
else
if(perhitungan.equalsIgnoreCase("okt")&&
perhitungan1.equalsIgnoreCase("des")){
int a=Integer.parseInt(coy,8);
hasil.setText(""+a);
perhitungan="des";
}
else
if(perhitungan.equalsIgnoreCase("okt")&&
perhitungan1.equalsIgnoreCase("bin")){
int a=Integer.parseInt(coy,8);
hasil.setText(""+Integer.toBinaryString(a));
perhitungan="bin";
}
else
if(perhitungan.equalsIgnoreCase("okt")&&
perhitungan1.equalsIgnoreCase("hex")){
int a=Integer.parseInt(coy,8);
hasil.setText(""+Integer.toHexString(a));
perhitungan="hex";
}
else
if(perhitungan.equalsIgnoreCase("hex")&&
perhitungan1.equalsIgnoreCase("des")){
int a=Integer.parseInt(coy,16);
hasil.setText(""+a);
perhitungan="des";
}
else
if(perhitungan.equalsIgnoreCase("hex")&&
perhitungan1.equalsIgnoreCase("bin")){
int a=Integer.parseInt(coy,16);
hasil.setText(""+Integer.toBinaryString(a));
perhitungan="bin";
}
else
if(perhitungan.equalsIgnoreCase("hex")&&
perhitungan1.equalsIgnoreCase("okt")){
int a=Integer.parseInt(coy,16);
hasil.setText(""+Integer.toOctalString(a));
perhitungan="okt";
}
else
if(perhitungan.equalsIgnoreCase("des")&&
perhitungan1.equalsIgnoreCase("bin")){
hasil.setText(""+Integer.toBinaryString(Integer.parseInt(coy)));
perhitungan="bin";
}
else
if(perhitungan.equalsIgnoreCase("des")&&
perhitungan1.equalsIgnoreCase("okt")){
hasil.setText(""+Integer.toOctalString(Integer.parseInt(coy)));
perhitungan="okt";
}
else
if(perhitungan.equalsIgnoreCase("des")&&
perhitungan1.equalsIgnoreCase("hex")){
hasil.setText(""+Integer.toHexString(Integer.parseInt(coy)));
perhitungan="hex";
}
}catch(NumberFormatException ab){
hasil.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() {
jPanel1 = new
javax.swing.JPanel();
jButton21 = new
javax.swing.JButton();
buttonGroup2 = new
javax.swing.ButtonGroup();
jPanel2 = new
javax.swing.JPanel();
jLabel1 = new
javax.swing.JLabel();
hasil = new
javax.swing.JTextField();
no1 = new
javax.swing.JButton();
no3 = new
javax.swing.JButton();
no5 = new
javax.swing.JButton();
no7 = new
javax.swing.JButton();
no9 = new
javax.swing.JButton();
no2 = new
javax.swing.JButton();
no4 = new
javax.swing.JButton();
no6 = new
javax.swing.JButton();
no8 = new
javax.swing.JButton();
no0 = new
javax.swing.JButton();
no00 = new
javax.swing.JButton();
koma = new
javax.swing.JButton();
jButton13 = new
javax.swing.JButton();
jButton14 = new
javax.swing.JButton();
jButton15 = new
javax.swing.JButton();
jButton16 = new
javax.swing.JButton();
jButton17 = new
javax.swing.JButton();
jButton18 = new
javax.swing.JButton();
jButton20 = new
javax.swing.JButton();
bin = new
javax.swing.JRadioButton();
hex = new
javax.swing.JRadioButton();
oct = new
javax.swing.JRadioButton();
jPanel3 = new
javax.swing.JPanel();
A = new javax.swing.JButton();
C = new javax.swing.JButton();
D = new javax.swing.JButton();
E = new javax.swing.JButton();
F = new javax.swing.JButton();
B = new javax.swing.JButton();
jButton19 = new
javax.swing.JButton();
Des = new
javax.swing.JRadioButton();
javax.swing.GroupLayout
jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100,
Short.MAX_VALUE)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100,
Short.MAX_VALUE)
);
jButton21.setText("jButton21");
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Kalkulator");
hasil.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
hasilActionPerformed(evt);
}
});
no1.setText("1");
no1.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
no1ActionPerformed(evt);
}
});
no3.setText("3");
no3.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
no3ActionPerformed(evt);
}
});
no5.setText("5");
no5.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
no5ActionPerformed(evt);
}
});
no7.setText("7");
no7.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
no7ActionPerformed(evt);
}
});
no9.setText("9");
no9.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
no9ActionPerformed(evt);
}
});
no2.setText("2");
no2.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
no2ActionPerformed(evt);
}
});
no4.setText("4");
no4.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
no4ActionPerformed(evt);
}
});
no6.setText("6");
no6.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
no6ActionPerformed(evt);
}
});
no8.setText("8");
no8.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
no8ActionPerformed(evt);
}
});
no0.setText("0");
no0.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
no0ActionPerformed(evt);
}
});
no00.setText("00");
no00.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
no00ActionPerformed(evt);
}
});
koma.setText(".");
koma.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
komaActionPerformed(evt);
}
});
jButton13.setText("=");
jButton13.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
jButton13ActionPerformed(evt);
}
});
jButton14.setText("CE");
jButton14.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
jButton14ActionPerformed(evt);
}
});
jButton15.setText("+");
jButton15.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
jButton15ActionPerformed(evt);
}
});
jButton16.setText("X");
jButton16.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
jButton16ActionPerformed(evt);
}
});
jButton17.setText("%");
jButton17.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
jButton17ActionPerformed(evt);
}
});
jButton18.setText("/");
jButton18.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
jButton18ActionPerformed(evt);
}
});
jButton20.setText("-");
jButton20.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
jButton20ActionPerformed(evt);
}
});
buttonGroup2.add(bin);
bin.setText("Biner");
bin.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
binActionPerformed(evt);
}
});
buttonGroup2.add(hex);
hex.setText("Hexadecimal");
hex.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
hexActionPerformed(evt);
}
});
buttonGroup2.add(oct);
oct.setText("Octal");
oct.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
octActionPerformed(evt);
}
});
A.setText("A");
A.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
AActionPerformed(evt);
}
});
C.setText("C");
C.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
CActionPerformed(evt);
}
});
D.setText("D");
D.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
DActionPerformed(evt);
}
});
E.setText("E");
E.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
EActionPerformed(evt);
}
});
F.setText("F");
F.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
FActionPerformed(evt);
}
});
B.setText("B");
B.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
BActionPerformed(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()
.addComponent(A)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(B)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(C))
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(D)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(E)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(F))
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(A)
.addComponent(C)
.addComponent(B))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(D)
.addComponent(E)
.addComponent(F)))
);
jButton19.setText("MOD");
jButton19.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
jButton19ActionPerformed(evt);
}
});
buttonGroup2.add(Des);
Des.setText("Desimal");
Des.addActionListener(new
java.awt.event.ActionListener() {
public void
actionPerformed(java.awt.event.ActionEvent evt) {
DesActionPerformed(evt);
}
});
javax.swing.GroupLayout
jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(hasil)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel2Layout.createSequentialGroup()
.addGap(0, 0,
Short.MAX_VALUE)
.addComponent(jLabel1,
javax.swing.GroupLayout.PREFERRED_SIZE, 89,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(147, 147, 147))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(no1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(no2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(no3))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(no4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(no5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(no6))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(no7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(no8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(no9))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(no0)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(no00, javax.swing.GroupLayout.PREFERRED_SIZE, 45,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(koma, javax.swing.GroupLayout.PREFERRED_SIZE, 37,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton13)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING,
false)
.addComponent(jButton14, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jButton15)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton20)))
.addGap(18, 18,
18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(hex)
.addComponent(bin)))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING,
false)
.addComponent(jButton17, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING,
jPanel2Layout.createSequentialGroup()
.addComponent(jButton16)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton18)))
.addGap(18, 18,
18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(oct)
.addComponent(Des))))
.addContainerGap(27,
Short.MAX_VALUE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jPanel3,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton19)
.addGap(0, 0,
Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel1,
javax.swing.GroupLayout.PREFERRED_SIZE, 24,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(hasil,
javax.swing.GroupLayout.PREFERRED_SIZE, 34,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(no1)
.addComponent(no2)
.addComponent(no3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(no4)
.addComponent(no5)
.addComponent(no6))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(no7)
.addComponent(no8)
.addComponent(no9))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(no0)
.addComponent(no00)
.addComponent(koma)))
.addComponent(jButton13, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton14)
.addComponent(bin))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton15)
.addComponent(jButton20)
.addComponent(hex))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton18)
.addComponent(jButton16)
.addComponent(oct))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton17, javax.swing.GroupLayout.PREFERRED_SIZE, 23,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Des))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton19, javax.swing.GroupLayout.PREFERRED_SIZE, 52,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18))
);
javax.swing.GroupLayout layout
= new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel2,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel2,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
private void
jButton20ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
jumlah = 2;
bil1 =
Double.parseDouble(hasil.getText());
hasil.setText("");
}
private void
jButton17ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
total =
Double.parseDouble(hasil.getText())/100;
hasil.setText(String.valueOf(total));
}
private void
no00ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here
hasil.setText(hasil.getText()+00);
}
private void
no7ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
hasil.setText(hasil.getText()+7);
}
private void
EActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
String E = "e";
hasil.setText(hasil.getText()+E);
}
private void
hasilActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
}
private void
no1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
hasil.setText(hasil.getText()+1);
}
private void
no2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
hasil.setText(hasil.getText()+2);
}
private void
no3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
hasil.setText(hasil.getText()+3);
}
private void
no4ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
hasil.setText(hasil.getText()+4);
}
private void
no5ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
hasil.setText(hasil.getText()+5);
}
private void
no6ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
hasil.setText(hasil.getText()+6);
}
private void
no8ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
hasil.setText(hasil.getText()+8);
}
private void
no9ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
hasil.setText(hasil.getText()+9);
}
private void
no0ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
hasil.setText(hasil.getText()+0);
}
private void
komaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
hasil.setText(hasil.getText()+".");
}
private void
jButton13ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
if(jumlah==1){
total =
bil1+Double.parseDouble(hasil.getText());
hasil.setText((String.valueOf(total)));
}else if(jumlah==2){
total =
bil1-Double.parseDouble(hasil.getText());
hasil.setText((String.valueOf(total)));
}else if(jumlah==3){
total =
bil1*Double.parseDouble(hasil.getText());
hasil.setText((String.valueOf(total)));
}else if(jumlah==4){
total =
bil1/Double.parseDouble(hasil.getText());
hasil.setText((String.valueOf(total)));
}else if(jumlah==5){
total =
bil1%Double.parseDouble(hasil.getText());
hasil.setText((String.valueOf(total)));
}else if(jumlah==6){
if(total<0){
hasil.setText("Syntax
Error");
}else{
total = Math.pow(bil1,
Double.parseDouble(hasil.getText()));
hasil.setText(String.valueOf(total)); } // TODO add your
handling code here:
}
}
private void
jButton16ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
jumlah = 3;
bil1 =
Double.parseDouble(hasil.getText());
hasil.setText("");
}
private void
jButton18ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
jumlah = 4;
bil1 =
Double.parseDouble(hasil.getText());
hasil.setText("");
}
private void
jButton15ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
jumlah = 1;
bil1 =
Double.parseDouble(hasil.getText());
hasil.setText("");
}
private void
jButton14ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
hasil.setText("0");
hasil.setText("");
}
private void
jButton19ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
jumlah = 5;
bil1 =
Double.parseDouble(hasil.getText());
hasil.setText("");
}
private void
octActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
no2.setEnabled(true);
no3.setEnabled(true);
no4.setEnabled(true);
no5.setEnabled(true);
no6.setEnabled(true);
no7.setEnabled(true);
no8.setEnabled(true);
no8.setEnabled(false);
no9.setEnabled(false);
no00.setEnabled(false);
koma.setEnabled(false);
A.setEnabled(false);
B.setEnabled(false);
C.setEnabled(false);
D.setEnabled(false);
E.setEnabled(false);
F.setEnabled(false);
perhitungan1="okt";
kalk();
}
private void
binActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
no2.setEnabled(false);
no3.setEnabled(false);
no4.setEnabled(false);
no5.setEnabled(false);
no6.setEnabled(false);
no7.setEnabled(false);
no8.setEnabled(false);
no9.setEnabled(false);
no00.setEnabled(false);
koma.setEnabled(false);
A.setEnabled(false);
B.setEnabled(false);
C.setEnabled(false);
D.setEnabled(false);
E.setEnabled(false);
F.setEnabled(false);
perhitungan1="bin";
kalk();
}
private void
hexActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
no1.setEnabled(true);
no2.setEnabled(true);
no3.setEnabled(true);
no4.setEnabled(true);
no5.setEnabled(true);
no6.setEnabled(true);
no7.setEnabled(true);
no8.setEnabled(true);
no9.setEnabled(true);
no0.setEnabled(true);
koma.setEnabled(false);
A.setEnabled(true);
B.setEnabled(true);
C.setEnabled(true);
D.setEnabled(true);
E.setEnabled(true);
F.setEnabled(true);
perhitungan1="hex";
kalk();
}
private void
DesActionPerformed(java.awt.event.ActionEvent evt) {
no2.setEnabled(true);
no3.setEnabled(true);
no4.setEnabled(true);
no5.setEnabled(true);
no6.setEnabled(true);
no7.setEnabled(true);
no8.setEnabled(true);
no9.setEnabled(true);
no00.setEnabled(true);
koma.setEnabled(true);
A.setEnabled(false);
B.setEnabled(false);
C.setEnabled(false);
D.setEnabled(false);
E.setEnabled(false);
F.setEnabled(false);
perhitungan1= "des";
kalk(); // TODO add your
handling code here:
}
private void
AActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
String A = "a";
hasil.setText(hasil.getText()+A);
}
private void
BActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
String A = "b";
hasil.setText(hasil.getText()+A);
}
private void
CActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
String A = "c";
hasil.setText(hasil.getText()+A);
}
private void
DActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
String A = "d";
hasil.setText(hasil.getText()+A);
}
private void
FActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code
here:
String A = "f";
hasil.setText(hasil.getText()+A);
}
/**
* @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(kalkulatorseno.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException
ex) {
java.util.logging.Logger.getLogger(kalkulatorseno.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException
ex) {
java.util.logging.Logger.getLogger(kalkulatorseno.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch
(javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(kalkulatorseno.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>
/* Create and display the form
*/
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new
kalkulatorseno().setVisible(true);
}
});
}
// Variables declaration - do not
modify
private javax.swing.JButton A;
private javax.swing.JButton B;
private javax.swing.JButton C;
private javax.swing.JButton D;
private javax.swing.JRadioButton
Des;
private javax.swing.JButton E;
private javax.swing.JButton F;
private javax.swing.JRadioButton
bin;
private javax.swing.ButtonGroup
buttonGroup2;
private javax.swing.JTextField
hasil;
private javax.swing.JRadioButton
hex;
private javax.swing.JButton
jButton13;
private javax.swing.JButton
jButton14;
private javax.swing.JButton
jButton15;
private javax.swing.JButton
jButton16;
private javax.swing.JButton
jButton17;
private javax.swing.JButton
jButton18;
private javax.swing.JButton
jButton19;
private javax.swing.JButton
jButton20;
private javax.swing.JButton
jButton21;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JButton koma;
private javax.swing.JButton no0;
private javax.swing.JButton no00;
private javax.swing.JButton no1;
private javax.swing.JButton no2;
private javax.swing.JButton no3;
private javax.swing.JButton no4;
private javax.swing.JButton no5;
private javax.swing.JButton no6;
private javax.swing.JButton no7;
private javax.swing.JButton no8;
private javax.swing.JButton no9;
private javax.swing.JRadioButton
oct;
// End of variables declaration
}
Posted by 23.06 and have
0
komentar
, Published at
Tidak ada komentar:
Posting Komentar