Nama : Moh Puji
Nim : 2012 420 002
Tugas : Algo II
package comunity;
import java.awt.Color;
import main.desimal;
import sun.awt.DisplayChangedListener;
/**
*
* @author aly
*/
public class hitungan extends javax.swing.JFrame {
Double plusminus;
Double firsDouble;
Double seconDouble;
Double totalDouble;
Double perDouble;
Double moDouble;
int plusClick;
int minusClick;
int multiplayClick;
int divideClick;
int des1Click;
int hex1Click;
int okt1nClick;
int bin1nClick;
int MoClik;
double persenclick;
int seh=1;
//int dobell;
private String Button1;
String huruf_mati;
String angka_mati;
/**
* Creates new form hitungan
*/
public hitungan() {
initComponents();
setTitle("Form Campuran by : Moh. Puji Asro");
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
des.setSelected(true);
}
String op="des",op1="";
void biokhex(){
try{
String mon=display.getText();
if(op.equalsIgnoreCase("bin")&& op1.equalsIgnoreCase("des")){
display.setText(""+Integer.parseInt(mon,2));
op="des";
}
else if(op.equalsIgnoreCase("bin")&& op1.equalsIgnoreCase("okt")){
int a=Integer.parseInt(mon,2);
display.setText(""+Integer.toOctalString(a));
op="okt";
}
else if(op.equalsIgnoreCase("bin")&& op1.equalsIgnoreCase("hex")){
int a=Integer.parseInt(mon,2);
display.setText(""+Integer.toHexString(a));
op="hex";
}
else if(op.equalsIgnoreCase("okt")&& op1.equalsIgnoreCase("des")){
int a=Integer.parseInt(mon,8);
display.setText(""+a);
op="des";
}
else if(op.equalsIgnoreCase("okt")&& op1.equalsIgnoreCase("bin")){
int a=Integer.parseInt(mon,8);
display.setText(""+Integer.toBinaryString(a));
op="bin";
}
else if(op.equalsIgnoreCase("okt")&& op1.equalsIgnoreCase("hex")){
int a=Integer.parseInt(mon,8);
display.setText(""+Integer.toHexString(a));
op="hex";
}
else if(op.equalsIgnoreCase("hex")&& op1.equalsIgnoreCase("des")){
int a=Integer.parseInt(mon,16);
display.setText(""+a);
op="des";
}else if(op.equalsIgnoreCase("hex")&& op1.equalsIgnoreCase("bin")){
int a=Integer.parseInt(mon,16);
display.setText(""+Integer.toBinaryString(a));
op="bin";
}else if(op.equalsIgnoreCase("hex")&& op1.equalsIgnoreCase("okt")){
int a=Integer.parseInt(mon,16);
display.setText(""+Integer.toOctalString(a));
op="okt";
}else if(op.equalsIgnoreCase("des")&& op1.equalsIgnoreCase("bin")){
display.setText(""+Integer.toBinaryString(Integer.parseInt(mon)));
op="bin";
}else if(op.equalsIgnoreCase("des")&& op1.equalsIgnoreCase("okt")){
display.setText(""+Integer.toOctalString(Integer.parseInt(mon)));
op="okt";
}else if(op.equalsIgnoreCase("des")&& op1.equalsIgnoreCase("hex")){
display.setText(""+Integer.toHexString(Integer.parseInt(mon)));
op="hex";
}
}
catch(NumberFormatException ab){
display.setText("error");
}
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
buttonGroup2 = new javax.swing.ButtonGroup();
buttonGroup3 = new javax.swing.ButtonGroup();
jPanel2 = new javax.swing.JPanel();
buttonGroup4 = new javax.swing.ButtonGroup();
jButton17 = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
jButton6 = new javax.swing.JButton();
jButton7 = new javax.swing.JButton();
jButton8 = new javax.swing.JButton();
jButton9 = new javax.swing.JButton();
desimal = new javax.swing.JButton();
jButton11 = new javax.swing.JButton();
penjumlahan = new javax.swing.JButton();
pengurangan = new javax.swing.JButton();
perkalian = new javax.swing.JButton();
hasil = new javax.swing.JButton();
pembagian = new javax.swing.JButton();
persen = new javax.swing.JButton();
jButton12 = new javax.swing.JButton();
jPanel3 = new javax.swing.JPanel();
e = new javax.swing.JButton();
a = new javax.swing.JButton();
b = new javax.swing.JButton();
c = new javax.swing.JButton();
d = new javax.swing.JButton();
f = new javax.swing.JButton();
hex = new javax.swing.JRadioButton();
des = new javax.swing.JRadioButton();
okt = new javax.swing.JRadioButton();
bin = new javax.swing.JRadioButton();
jButton10 = new javax.swing.JButton();
jPanel4 = new javax.swing.JPanel();
display = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jButton17.setText("jButton17");
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPanel1.setBackground(new java.awt.Color(102, 0, 102));
jPanel1.setForeground(new java.awt.Color(0, 0, 204));
jPanel1.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
jButton1.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
jButton1.setForeground(new java.awt.Color(0, 0, 255));
jButton1.setText("1");
jButton1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
jButton2.setForeground(new java.awt.Color(0, 0, 255));
jButton2.setText("2");
jButton2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton3.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
jButton3.setForeground(new java.awt.Color(0, 0, 255));
jButton3.setText("3");
jButton3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jButton4.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
jButton4.setForeground(new java.awt.Color(0, 0, 255));
jButton4.setText("4");
jButton4.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
jButton5.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
jButton5.setForeground(new java.awt.Color(0, 0, 255));
jButton5.setText("5");
jButton5.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});
jButton6.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
jButton6.setForeground(new java.awt.Color(0, 0, 255));
jButton6.setText("6");
jButton6.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
jButton6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton6ActionPerformed(evt);
}
});
jButton7.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
jButton7.setForeground(new java.awt.Color(0, 0, 255));
jButton7.setText("7");
jButton7.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
jButton7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton7ActionPerformed(evt);
}
});
jButton8.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
jButton8.setForeground(new java.awt.Color(0, 0, 255));
jButton8.setText("8");
jButton8.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
jButton8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton8ActionPerformed(evt);
}
});
jButton9.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
jButton9.setForeground(new java.awt.Color(0, 0, 255));
jButton9.setText("9");
jButton9.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
jButton9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton9ActionPerformed(evt);
}
});
desimal.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
desimal.setForeground(new java.awt.Color(0, 0, 255));
desimal.setText(".");
desimal.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
desimal.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
desimalActionPerformed(evt);
}
});
jButton11.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
jButton11.setForeground(new java.awt.Color(0, 0, 255));
jButton11.setText("0");
jButton11.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
jButton11.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton11ActionPerformed(evt);
}
});
penjumlahan.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
penjumlahan.setForeground(new java.awt.Color(0, 0, 255));
penjumlahan.setText("+");
penjumlahan.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
penjumlahan.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
penjumlahanActionPerformed(evt);
}
});
pengurangan.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
pengurangan.setForeground(new java.awt.Color(0, 0, 255));
pengurangan.setText("-");
pengurangan.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
pengurangan.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
penguranganActionPerformed(evt);
}
});
perkalian.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
perkalian.setForeground(new java.awt.Color(0, 0, 255));
perkalian.setText("x");
perkalian.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
perkalian.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
perkalianActionPerformed(evt);
}
});
hasil.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
hasil.setForeground(new java.awt.Color(0, 0, 255));
hasil.setText("Hasil !!!");
hasil.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 51, 0), 2));
hasil.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
hasilActionPerformed(evt);
}
});
pembagian.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
pembagian.setForeground(new java.awt.Color(0, 0, 255));
pembagian.setText("/");
pembagian.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
pembagian.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
pembagianActionPerformed(evt);
}
});
persen.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
persen.setForeground(new java.awt.Color(0, 0, 255));
persen.setText("%");
persen.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
persen.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
persenActionPerformed(evt);
}
});
jButton12.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
jButton12.setForeground(new java.awt.Color(0, 0, 255));
jButton12.setText("+/-");
jButton12.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
jButton12.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton12ActionPerformed(evt);
}
});
jPanel3.setBackground(new java.awt.Color(51, 255, 255));
e.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
e.setForeground(new java.awt.Color(0, 0, 204));
e.setText("E");
e.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 255)));
e.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
eActionPerformed(evt);
}
});
a.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
a.setForeground(new java.awt.Color(0, 0, 204));
a.setText("A");
a.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 255)));
a.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
aActionPerformed(evt);
}
});
b.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
b.setForeground(new java.awt.Color(0, 0, 204));
b.setText("B");
b.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 255)));
b.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bActionPerformed(evt);
}
});
c.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
c.setForeground(new java.awt.Color(0, 0, 204));
c.setText("C");
c.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 255)));
c.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cActionPerformed(evt);
}
});
d.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
d.setForeground(new java.awt.Color(0, 0, 204));
d.setText("D");
d.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 255)));
d.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
dActionPerformed(evt);
}
});
f.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
f.setForeground(new java.awt.Color(0, 0, 204));
f.setText("F");
f.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 255)));
f.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
fActionPerformed(evt);
}
});
buttonGroup1.add(hex);
hex.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
hex.setForeground(new java.awt.Color(0, 0, 204));
hex.setText("Hex");
hex.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 255)));
hex.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
hex.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
hexActionPerformed(evt);
}
});
buttonGroup1.add(des);
des.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
des.setForeground(new java.awt.Color(0, 0, 204));
des.setText("Dec");
des.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 255)));
des.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
des.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
desActionPerformed(evt);
}
});
buttonGroup1.add(okt);
okt.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
okt.setForeground(new java.awt.Color(0, 0, 204));
okt.setText("Okt");
okt.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 255)));
okt.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
okt.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
oktActionPerformed(evt);
}
});
buttonGroup1.add(bin);
bin.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
bin.setForeground(new java.awt.Color(0, 0, 204));
bin.setText("Bin");
bin.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 255)));
bin.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
bin.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
binActionPerformed(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.LEADING)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(bin, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(10, 10, 10)
.addComponent(okt, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(c, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(b, javax.swing.GroupLayout.DEFAULT_SIZE, 65, Short.MAX_VALUE)
.addComponent(a, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(f, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(e, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(d, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(des, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(hex, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(16, Short.MAX_VALUE))
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(10, 10, 10)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(des, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(hex, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(bin, javax.swing.GroupLayout.DEFAULT_SIZE, 37, Short.MAX_VALUE)
.addComponent(okt, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, 13, Short.MAX_VALUE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(d, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(e, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(a, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(b, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 14, Short.MAX_VALUE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(f, javax.swing.GroupLayout.DEFAULT_SIZE, 39, Short.MAX_VALUE)
.addGap(12, 12, 12))
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(1, 1, 1)
.addComponent(c, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())))
);
jButton10.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
jButton10.setForeground(new java.awt.Color(0, 0, 255));
jButton10.setText("Hapus !!!");
jButton10.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
jButton10.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton10ActionPerformed(evt);
}
});
jPanel4.setBackground(new java.awt.Color(51, 51, 255));
jPanel4.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 51, 0), 2));
display.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
display.setForeground(new java.awt.Color(0, 0, 204));
display.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 51, 0), 2));
display.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
display.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
displayActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addComponent(display, javax.swing.GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE)
.addContainerGap())
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addComponent(display)
.addContainerGap())
);
jLabel1.setFont(new java.awt.Font("Vlaanderen Chiseled NF", 1, 24)); // NOI18N
jLabel1.setForeground(new java.awt.Color(255, 51, 0));
jLabel1.setText("KALKULATOR");
jLabel1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 102, 0), 1, true));
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(22, 22, 22)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jButton10, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(desimal, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton7, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE))))))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(persen, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(28, 28, 28)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(penjumlahan, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(pembagian, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pengurangan, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(perkalian, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGap(21, 21, 21)
.addComponent(jButton12, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(hasil, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(23, 23, 23))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(187, 187, 187)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(hasil, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(penjumlahan, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(15, 15, 15)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(pengurangan, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(9, 9, 9)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton9, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(perkalian, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(desimal, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(pembagian, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(persen, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(5, 5, 5)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton10, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton12, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(27, 27, 27))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 403, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+2);
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
// display.setText("1");
display.setText(display.getText()+1);
}
private void penjumlahanActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
firsDouble=(Double.parseDouble(String.valueOf(display.getText())));
display.setText("");
plusClick=(1);
seh=1;
}
private void penguranganActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
firsDouble = (Double.parseDouble(String.valueOf(display.getText())));
display.setText("");
minusClick=(1);
}
private void perkalianActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
firsDouble = (Double.parseDouble(String.valueOf(display.getText())));
display.setText("");
multiplayClick=(1);
}
private void pembagianActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
firsDouble=(Double.parseDouble(String.valueOf(display.getText())));
// seconDouble=(Double.parseDouble(String.valueOf(display.getText())));
display.setText("");
divideClick = (1) ;
}
private void hasilActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
seconDouble=(Double.parseDouble(String.valueOf(display.getText())));
if(plusClick>0){
totalDouble=firsDouble+seconDouble;
display.setText((String.valueOf(totalDouble)));
// firsDouble=0;
// seconDouble = 0;
plusClick=0;
// divideClick=0;
}
if(minusClick>0){
totalDouble=firsDouble-seconDouble;
display.setText((String.valueOf(totalDouble)));
minusClick=0;
multiplayClick=0;
// firsDouble=0;
// seconDouble = 0;
}
if(multiplayClick>0){
totalDouble=firsDouble*seconDouble;
display.setText((String.valueOf(totalDouble)));
// firsDouble=0;
// seconDouble = 0;
multiplayClick=0;
// divideClick=0;
}
if(divideClick>0){
totalDouble=firsDouble/seconDouble;
display.setText((String.valueOf(totalDouble)));
// firsDouble=0;
// seconDouble = 0;
divideClick=0;
// divideClick=0;
display.setBackground(Color.red);
}else if(persenclick>0){
firsDouble = (Double.parseDouble(String.valueOf("1")));
display.setText((String.valueOf((firsDouble*100)/100)));
// firsDouble=0;
// seconDouble = 0;
persenclick=0;
}
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+3);
}
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+5);
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+4);
}
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+6);
}
private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+7);
}
private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+8);
}
private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+9);;
}
private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(" ");
display.setBackground(Color.white);
}
private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+0);
}
private void desimalActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (seh==1) {
seh=0;
display.setText(display.getText()+".");
}
}
private void persenActionPerformed(java.awt.event.ActionEvent evt) {
persenclick=Double.parseDouble(display.getText());
display.setText(String.valueOf((persenclick/100)));
}
private void aActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+"A");
}
private void bActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+"B");
}
private void cActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+"C");
}
private void dActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+"D");
}
private void desActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
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);
jButton11.setEnabled(true);
desimal.setEnabled(false);
a.setEnabled(false);
b.setEnabled(false);
c.setEnabled(false);
d.setEnabled(false);
e.setEnabled(false);
f.setEnabled(false);
op1="des";
biokhex();
operator_mati(true);
huruf_mati(false);
angka_mati(true);
}
private void hexActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
jButton2.setEnabled(true);
jButton3.setEnabled(true);
jButton4.setEnabled(true);
jButton5.setEnabled(true);
jButton6.setEnabled(true);
jButton7.setEnabled(true);
jButton8.setEnabled(true);
jButton9.setEnabled(true);
desimal.setEnabled(true);
a.setEnabled(true);
b.setEnabled(true);
c.setEnabled(true);
d.setEnabled(true);
e.setEnabled(true);
f.setEnabled(true);
op1="hex";
biokhex();
operator_mati(false);
huruf_mati(true);
angka_mati(true);
firsDouble = (Double.parseDouble(String.valueOf(display.getText())));
display.setText("");
hex1Click=(1);
}
private void binActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
jButton2.setEnabled(false) ;
jButton3.setEnabled(false);
jButton4.setEnabled(false);
jButton5.setEnabled(false);
jButton6.setEnabled(false);
jButton7.setEnabled(false);
jButton8.setEnabled(false);
jButton9.setEnabled(false);
desimal.setEnabled(true);
jButton11.setEnabled(true);
a.setEnabled(false);
b.setEnabled(false);
c.setEnabled(false);
d.setEnabled(false);
e.setEnabled(false);
f.setEnabled(false);
op1="bin";
biokhex();
operator_mati(false);
huruf_mati(false);
angka_mati(true);
firsDouble = (Double.parseDouble(String.valueOf(display.getText())));
display.setText("");
bin1nClick = (1);
}
private void oktActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
//
jButton2.setEnabled(true) ;
jButton3.setEnabled(true);
jButton4.setEnabled(true);
jButton5.setEnabled(true);
jButton6.setEnabled(true);
jButton7.setEnabled(true);
jButton8.setEnabled(true);
jButton9.setEnabled(false);
desimal.setEnabled(false);
jButton11.setEnabled(true);
a.setEnabled(false);
b.setEnabled(false);
c.setEnabled(false);
d.setEnabled(false);
e.setEnabled(false);
f.setEnabled(false);
op1="okt";
biokhex();
operator_mati(false);
huruf_mati(false);
angka_mati(true);
firsDouble = (Double.parseDouble(String.valueOf(display.getText())));
display.setText("");
bin1nClick = (1);
}
private void displayActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void eActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+"E");
}
private void fActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+"F");
}
private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
firsDouble = Double.parseDouble(display.getText())*-1;
display.setText("");
MoClik = (1);
display.setText(String.valueOf(firsDouble));
}
/**
* @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(hitungan.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(hitungan.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(hitungan.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(hitungan.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 hitungan().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton a;
private javax.swing.JButton b;
private javax.swing.JRadioButton bin;
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.ButtonGroup buttonGroup2;
private javax.swing.ButtonGroup buttonGroup3;
private javax.swing.ButtonGroup buttonGroup4;
private javax.swing.JButton c;
private javax.swing.JButton d;
private javax.swing.JRadioButton des;
private javax.swing.JButton desimal;
private javax.swing.JTextField display;
private javax.swing.JButton e;
private javax.swing.JButton f;
private javax.swing.JButton hasil;
private javax.swing.JRadioButton hex;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton10;
private javax.swing.JButton jButton11;
private javax.swing.JButton jButton12;
private javax.swing.JButton jButton17;
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.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JRadioButton okt;
private javax.swing.JButton pembagian;
private javax.swing.JButton pengurangan;
private javax.swing.JButton penjumlahan;
private javax.swing.JButton perkalian;
private javax.swing.JButton persen;
// End of variables declaration
/**
* @return the jButton1
*/
public javax.swing.JButton getjButton1() {
return jButton1;
}
/**
* @return the jButton11
*/
public javax.swing.JButton getjButton11() {
return jButton11;
}
/**
* @return the jButton2
*/
public javax.swing.JButton getjButton2() {
return jButton2;
}
/**
* @return the jButton3
*/
public javax.swing.JButton getjButton3() {
return jButton3;
}
/**
* @return the jButton4
*/
public javax.swing.JButton getjButton4() {
return jButton4;
}
/**
* @return the jButton5
*/
public javax.swing.JButton getjButton5() {
return jButton5;
}
/**
* @return the jButton6
*/
public javax.swing.JButton getjButton6() {
return jButton6;
}
/**
* @return the jButton7
*/
public javax.swing.JButton getjButton7() {
return jButton7;
}
/**
* @return the jButton8
*/
public javax.swing.JButton getjButton8() {
return jButton8;
}
/**
* @return the jButton9
*/
public javax.swing.JButton getjButton9() {
return jButton9;
}
private void operator_mati(boolean b) {
}
private void angka_mati(boolean b) {
}
private void huruf_mati(boolean b) {
import java.awt.Color;
import main.desimal;
import sun.awt.DisplayChangedListener;
/**
*
* @author aly
*/
public class hitungan extends javax.swing.JFrame {
Double plusminus;
Double firsDouble;
Double seconDouble;
Double totalDouble;
Double perDouble;
Double moDouble;
int plusClick;
int minusClick;
int multiplayClick;
int divideClick;
int des1Click;
int hex1Click;
int okt1nClick;
int bin1nClick;
int MoClik;
double persenclick;
int seh=1;
//int dobell;
private String Button1;
String huruf_mati;
String angka_mati;
/**
* Creates new form hitungan
*/
public hitungan() {
initComponents();
setTitle("Form Campuran by : Moh. Puji Asro");
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
des.setSelected(true);
}
String op="des",op1="";
void biokhex(){
try{
String mon=display.getText();
if(op.equalsIgnoreCase("bin")&& op1.equalsIgnoreCase("des")){
display.setText(""+Integer.parseInt(mon,2));
op="des";
}
else if(op.equalsIgnoreCase("bin")&& op1.equalsIgnoreCase("okt")){
int a=Integer.parseInt(mon,2);
display.setText(""+Integer.toOctalString(a));
op="okt";
}
else if(op.equalsIgnoreCase("bin")&& op1.equalsIgnoreCase("hex")){
int a=Integer.parseInt(mon,2);
display.setText(""+Integer.toHexString(a));
op="hex";
}
else if(op.equalsIgnoreCase("okt")&& op1.equalsIgnoreCase("des")){
int a=Integer.parseInt(mon,8);
display.setText(""+a);
op="des";
}
else if(op.equalsIgnoreCase("okt")&& op1.equalsIgnoreCase("bin")){
int a=Integer.parseInt(mon,8);
display.setText(""+Integer.toBinaryString(a));
op="bin";
}
else if(op.equalsIgnoreCase("okt")&& op1.equalsIgnoreCase("hex")){
int a=Integer.parseInt(mon,8);
display.setText(""+Integer.toHexString(a));
op="hex";
}
else if(op.equalsIgnoreCase("hex")&& op1.equalsIgnoreCase("des")){
int a=Integer.parseInt(mon,16);
display.setText(""+a);
op="des";
}else if(op.equalsIgnoreCase("hex")&& op1.equalsIgnoreCase("bin")){
int a=Integer.parseInt(mon,16);
display.setText(""+Integer.toBinaryString(a));
op="bin";
}else if(op.equalsIgnoreCase("hex")&& op1.equalsIgnoreCase("okt")){
int a=Integer.parseInt(mon,16);
display.setText(""+Integer.toOctalString(a));
op="okt";
}else if(op.equalsIgnoreCase("des")&& op1.equalsIgnoreCase("bin")){
display.setText(""+Integer.toBinaryString(Integer.parseInt(mon)));
op="bin";
}else if(op.equalsIgnoreCase("des")&& op1.equalsIgnoreCase("okt")){
display.setText(""+Integer.toOctalString(Integer.parseInt(mon)));
op="okt";
}else if(op.equalsIgnoreCase("des")&& op1.equalsIgnoreCase("hex")){
display.setText(""+Integer.toHexString(Integer.parseInt(mon)));
op="hex";
}
}
catch(NumberFormatException ab){
display.setText("error");
}
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
buttonGroup2 = new javax.swing.ButtonGroup();
buttonGroup3 = new javax.swing.ButtonGroup();
jPanel2 = new javax.swing.JPanel();
buttonGroup4 = new javax.swing.ButtonGroup();
jButton17 = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
jButton6 = new javax.swing.JButton();
jButton7 = new javax.swing.JButton();
jButton8 = new javax.swing.JButton();
jButton9 = new javax.swing.JButton();
desimal = new javax.swing.JButton();
jButton11 = new javax.swing.JButton();
penjumlahan = new javax.swing.JButton();
pengurangan = new javax.swing.JButton();
perkalian = new javax.swing.JButton();
hasil = new javax.swing.JButton();
pembagian = new javax.swing.JButton();
persen = new javax.swing.JButton();
jButton12 = new javax.swing.JButton();
jPanel3 = new javax.swing.JPanel();
e = new javax.swing.JButton();
a = new javax.swing.JButton();
b = new javax.swing.JButton();
c = new javax.swing.JButton();
d = new javax.swing.JButton();
f = new javax.swing.JButton();
hex = new javax.swing.JRadioButton();
des = new javax.swing.JRadioButton();
okt = new javax.swing.JRadioButton();
bin = new javax.swing.JRadioButton();
jButton10 = new javax.swing.JButton();
jPanel4 = new javax.swing.JPanel();
display = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jButton17.setText("jButton17");
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPanel1.setBackground(new java.awt.Color(102, 0, 102));
jPanel1.setForeground(new java.awt.Color(0, 0, 204));
jPanel1.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
jButton1.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
jButton1.setForeground(new java.awt.Color(0, 0, 255));
jButton1.setText("1");
jButton1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton2.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
jButton2.setForeground(new java.awt.Color(0, 0, 255));
jButton2.setText("2");
jButton2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jButton3.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
jButton3.setForeground(new java.awt.Color(0, 0, 255));
jButton3.setText("3");
jButton3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jButton4.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
jButton4.setForeground(new java.awt.Color(0, 0, 255));
jButton4.setText("4");
jButton4.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
jButton5.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
jButton5.setForeground(new java.awt.Color(0, 0, 255));
jButton5.setText("5");
jButton5.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});
jButton6.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
jButton6.setForeground(new java.awt.Color(0, 0, 255));
jButton6.setText("6");
jButton6.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
jButton6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton6ActionPerformed(evt);
}
});
jButton7.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
jButton7.setForeground(new java.awt.Color(0, 0, 255));
jButton7.setText("7");
jButton7.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
jButton7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton7ActionPerformed(evt);
}
});
jButton8.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
jButton8.setForeground(new java.awt.Color(0, 0, 255));
jButton8.setText("8");
jButton8.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
jButton8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton8ActionPerformed(evt);
}
});
jButton9.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
jButton9.setForeground(new java.awt.Color(0, 0, 255));
jButton9.setText("9");
jButton9.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
jButton9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton9ActionPerformed(evt);
}
});
desimal.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
desimal.setForeground(new java.awt.Color(0, 0, 255));
desimal.setText(".");
desimal.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
desimal.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
desimalActionPerformed(evt);
}
});
jButton11.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
jButton11.setForeground(new java.awt.Color(0, 0, 255));
jButton11.setText("0");
jButton11.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
jButton11.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton11ActionPerformed(evt);
}
});
penjumlahan.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
penjumlahan.setForeground(new java.awt.Color(0, 0, 255));
penjumlahan.setText("+");
penjumlahan.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
penjumlahan.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
penjumlahanActionPerformed(evt);
}
});
pengurangan.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
pengurangan.setForeground(new java.awt.Color(0, 0, 255));
pengurangan.setText("-");
pengurangan.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
pengurangan.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
penguranganActionPerformed(evt);
}
});
perkalian.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
perkalian.setForeground(new java.awt.Color(0, 0, 255));
perkalian.setText("x");
perkalian.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
perkalian.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
perkalianActionPerformed(evt);
}
});
hasil.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
hasil.setForeground(new java.awt.Color(0, 0, 255));
hasil.setText("Hasil !!!");
hasil.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 51, 0), 2));
hasil.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
hasilActionPerformed(evt);
}
});
pembagian.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
pembagian.setForeground(new java.awt.Color(0, 0, 255));
pembagian.setText("/");
pembagian.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
pembagian.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
pembagianActionPerformed(evt);
}
});
persen.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
persen.setForeground(new java.awt.Color(0, 0, 255));
persen.setText("%");
persen.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
persen.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
persenActionPerformed(evt);
}
});
jButton12.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
jButton12.setForeground(new java.awt.Color(0, 0, 255));
jButton12.setText("+/-");
jButton12.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
jButton12.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton12ActionPerformed(evt);
}
});
jPanel3.setBackground(new java.awt.Color(51, 255, 255));
e.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
e.setForeground(new java.awt.Color(0, 0, 204));
e.setText("E");
e.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 255)));
e.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
eActionPerformed(evt);
}
});
a.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
a.setForeground(new java.awt.Color(0, 0, 204));
a.setText("A");
a.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 255)));
a.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
aActionPerformed(evt);
}
});
b.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
b.setForeground(new java.awt.Color(0, 0, 204));
b.setText("B");
b.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 255)));
b.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bActionPerformed(evt);
}
});
c.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
c.setForeground(new java.awt.Color(0, 0, 204));
c.setText("C");
c.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 255)));
c.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cActionPerformed(evt);
}
});
d.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
d.setForeground(new java.awt.Color(0, 0, 204));
d.setText("D");
d.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 255)));
d.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
dActionPerformed(evt);
}
});
f.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
f.setForeground(new java.awt.Color(0, 0, 204));
f.setText("F");
f.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 255)));
f.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
fActionPerformed(evt);
}
});
buttonGroup1.add(hex);
hex.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
hex.setForeground(new java.awt.Color(0, 0, 204));
hex.setText("Hex");
hex.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 255)));
hex.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
hex.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
hexActionPerformed(evt);
}
});
buttonGroup1.add(des);
des.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
des.setForeground(new java.awt.Color(0, 0, 204));
des.setText("Dec");
des.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 255)));
des.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
des.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
desActionPerformed(evt);
}
});
buttonGroup1.add(okt);
okt.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
okt.setForeground(new java.awt.Color(0, 0, 204));
okt.setText("Okt");
okt.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 255)));
okt.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
okt.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
oktActionPerformed(evt);
}
});
buttonGroup1.add(bin);
bin.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
bin.setForeground(new java.awt.Color(0, 0, 204));
bin.setText("Bin");
bin.setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 255)));
bin.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
bin.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
binActionPerformed(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.LEADING)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(bin, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(10, 10, 10)
.addComponent(okt, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(c, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(b, javax.swing.GroupLayout.DEFAULT_SIZE, 65, Short.MAX_VALUE)
.addComponent(a, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(f, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(e, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(d, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(des, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(hex, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(16, Short.MAX_VALUE))
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(10, 10, 10)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(des, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(hex, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(bin, javax.swing.GroupLayout.DEFAULT_SIZE, 37, Short.MAX_VALUE)
.addComponent(okt, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, 13, Short.MAX_VALUE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(d, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(e, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(a, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(b, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 14, Short.MAX_VALUE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(f, javax.swing.GroupLayout.DEFAULT_SIZE, 39, Short.MAX_VALUE)
.addGap(12, 12, 12))
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(1, 1, 1)
.addComponent(c, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())))
);
jButton10.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
jButton10.setForeground(new java.awt.Color(0, 0, 255));
jButton10.setText("Hapus !!!");
jButton10.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 204), 2));
jButton10.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton10ActionPerformed(evt);
}
});
jPanel4.setBackground(new java.awt.Color(51, 51, 255));
jPanel4.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 51, 0), 2));
display.setFont(new java.awt.Font("Bodoni MT Black", 1, 18)); // NOI18N
display.setForeground(new java.awt.Color(0, 0, 204));
display.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 51, 0), 2));
display.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
display.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
displayActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addComponent(display, javax.swing.GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE)
.addContainerGap())
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addComponent(display)
.addContainerGap())
);
jLabel1.setFont(new java.awt.Font("Vlaanderen Chiseled NF", 1, 24)); // NOI18N
jLabel1.setForeground(new java.awt.Color(255, 51, 0));
jLabel1.setText("KALKULATOR");
jLabel1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 102, 0), 1, true));
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(22, 22, 22)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 61, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jButton10, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(desimal, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton7, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE))))))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jButton6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(persen, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(28, 28, 28)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(penjumlahan, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(pembagian, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pengurangan, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(perkalian, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGap(21, 21, 21)
.addComponent(jButton12, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(hasil, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(23, 23, 23))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(187, 187, 187)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(hasil, javax.swing.GroupLayout.PREFERRED_SIZE, 63, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(penjumlahan, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(15, 15, 15)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(pengurangan, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(9, 9, 9)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton9, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(perkalian, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(desimal, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(pembagian, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(persen, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(5, 5, 5)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton10, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton12, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(27, 27, 27))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 403, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+2);
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
// display.setText("1");
display.setText(display.getText()+1);
}
private void penjumlahanActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
firsDouble=(Double.parseDouble(String.valueOf(display.getText())));
display.setText("");
plusClick=(1);
seh=1;
}
private void penguranganActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
firsDouble = (Double.parseDouble(String.valueOf(display.getText())));
display.setText("");
minusClick=(1);
}
private void perkalianActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
firsDouble = (Double.parseDouble(String.valueOf(display.getText())));
display.setText("");
multiplayClick=(1);
}
private void pembagianActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
firsDouble=(Double.parseDouble(String.valueOf(display.getText())));
// seconDouble=(Double.parseDouble(String.valueOf(display.getText())));
display.setText("");
divideClick = (1) ;
}
private void hasilActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
seconDouble=(Double.parseDouble(String.valueOf(display.getText())));
if(plusClick>0){
totalDouble=firsDouble+seconDouble;
display.setText((String.valueOf(totalDouble)));
// firsDouble=0;
// seconDouble = 0;
plusClick=0;
// divideClick=0;
}
if(minusClick>0){
totalDouble=firsDouble-seconDouble;
display.setText((String.valueOf(totalDouble)));
minusClick=0;
multiplayClick=0;
// firsDouble=0;
// seconDouble = 0;
}
if(multiplayClick>0){
totalDouble=firsDouble*seconDouble;
display.setText((String.valueOf(totalDouble)));
// firsDouble=0;
// seconDouble = 0;
multiplayClick=0;
// divideClick=0;
}
if(divideClick>0){
totalDouble=firsDouble/seconDouble;
display.setText((String.valueOf(totalDouble)));
// firsDouble=0;
// seconDouble = 0;
divideClick=0;
// divideClick=0;
display.setBackground(Color.red);
}else if(persenclick>0){
firsDouble = (Double.parseDouble(String.valueOf("1")));
display.setText((String.valueOf((firsDouble*100)/100)));
// firsDouble=0;
// seconDouble = 0;
persenclick=0;
}
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+3);
}
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+5);
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+4);
}
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+6);
}
private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+7);
}
private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+8);
}
private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+9);;
}
private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(" ");
display.setBackground(Color.white);
}
private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+0);
}
private void desimalActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (seh==1) {
seh=0;
display.setText(display.getText()+".");
}
}
private void persenActionPerformed(java.awt.event.ActionEvent evt) {
persenclick=Double.parseDouble(display.getText());
display.setText(String.valueOf((persenclick/100)));
}
private void aActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+"A");
}
private void bActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+"B");
}
private void cActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+"C");
}
private void dActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+"D");
}
private void desActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
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);
jButton11.setEnabled(true);
desimal.setEnabled(false);
a.setEnabled(false);
b.setEnabled(false);
c.setEnabled(false);
d.setEnabled(false);
e.setEnabled(false);
f.setEnabled(false);
op1="des";
biokhex();
operator_mati(true);
huruf_mati(false);
angka_mati(true);
}
private void hexActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
jButton2.setEnabled(true);
jButton3.setEnabled(true);
jButton4.setEnabled(true);
jButton5.setEnabled(true);
jButton6.setEnabled(true);
jButton7.setEnabled(true);
jButton8.setEnabled(true);
jButton9.setEnabled(true);
desimal.setEnabled(true);
a.setEnabled(true);
b.setEnabled(true);
c.setEnabled(true);
d.setEnabled(true);
e.setEnabled(true);
f.setEnabled(true);
op1="hex";
biokhex();
operator_mati(false);
huruf_mati(true);
angka_mati(true);
firsDouble = (Double.parseDouble(String.valueOf(display.getText())));
display.setText("");
hex1Click=(1);
}
private void binActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
jButton2.setEnabled(false) ;
jButton3.setEnabled(false);
jButton4.setEnabled(false);
jButton5.setEnabled(false);
jButton6.setEnabled(false);
jButton7.setEnabled(false);
jButton8.setEnabled(false);
jButton9.setEnabled(false);
desimal.setEnabled(true);
jButton11.setEnabled(true);
a.setEnabled(false);
b.setEnabled(false);
c.setEnabled(false);
d.setEnabled(false);
e.setEnabled(false);
f.setEnabled(false);
op1="bin";
biokhex();
operator_mati(false);
huruf_mati(false);
angka_mati(true);
firsDouble = (Double.parseDouble(String.valueOf(display.getText())));
display.setText("");
bin1nClick = (1);
}
private void oktActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
//
jButton2.setEnabled(true) ;
jButton3.setEnabled(true);
jButton4.setEnabled(true);
jButton5.setEnabled(true);
jButton6.setEnabled(true);
jButton7.setEnabled(true);
jButton8.setEnabled(true);
jButton9.setEnabled(false);
desimal.setEnabled(false);
jButton11.setEnabled(true);
a.setEnabled(false);
b.setEnabled(false);
c.setEnabled(false);
d.setEnabled(false);
e.setEnabled(false);
f.setEnabled(false);
op1="okt";
biokhex();
operator_mati(false);
huruf_mati(false);
angka_mati(true);
firsDouble = (Double.parseDouble(String.valueOf(display.getText())));
display.setText("");
bin1nClick = (1);
}
private void displayActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void eActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+"E");
}
private void fActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText(display.getText()+"F");
}
private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
firsDouble = Double.parseDouble(display.getText())*-1;
display.setText("");
MoClik = (1);
display.setText(String.valueOf(firsDouble));
}
/**
* @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(hitungan.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(hitungan.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(hitungan.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(hitungan.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 hitungan().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton a;
private javax.swing.JButton b;
private javax.swing.JRadioButton bin;
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.ButtonGroup buttonGroup2;
private javax.swing.ButtonGroup buttonGroup3;
private javax.swing.ButtonGroup buttonGroup4;
private javax.swing.JButton c;
private javax.swing.JButton d;
private javax.swing.JRadioButton des;
private javax.swing.JButton desimal;
private javax.swing.JTextField display;
private javax.swing.JButton e;
private javax.swing.JButton f;
private javax.swing.JButton hasil;
private javax.swing.JRadioButton hex;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton10;
private javax.swing.JButton jButton11;
private javax.swing.JButton jButton12;
private javax.swing.JButton jButton17;
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.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JRadioButton okt;
private javax.swing.JButton pembagian;
private javax.swing.JButton pengurangan;
private javax.swing.JButton penjumlahan;
private javax.swing.JButton perkalian;
private javax.swing.JButton persen;
// End of variables declaration
/**
* @return the jButton1
*/
public javax.swing.JButton getjButton1() {
return jButton1;
}
/**
* @return the jButton11
*/
public javax.swing.JButton getjButton11() {
return jButton11;
}
/**
* @return the jButton2
*/
public javax.swing.JButton getjButton2() {
return jButton2;
}
/**
* @return the jButton3
*/
public javax.swing.JButton getjButton3() {
return jButton3;
}
/**
* @return the jButton4
*/
public javax.swing.JButton getjButton4() {
return jButton4;
}
/**
* @return the jButton5
*/
public javax.swing.JButton getjButton5() {
return jButton5;
}
/**
* @return the jButton6
*/
public javax.swing.JButton getjButton6() {
return jButton6;
}
/**
* @return the jButton7
*/
public javax.swing.JButton getjButton7() {
return jButton7;
}
/**
* @return the jButton8
*/
public javax.swing.JButton getjButton8() {
return jButton8;
}
/**
* @return the jButton9
*/
public javax.swing.JButton getjButton9() {
return jButton9;
}
private void operator_mati(boolean b) {
}
private void angka_mati(boolean b) {
}
private void huruf_mati(boolean b) {
}
}
output
Posted by 00.29 and have
0
komentar
, Published at
Tidak ada komentar:
Posting Komentar