Program Java GUI "Kamus"



TAMPILAN AWAL KAMUS
C:\Users\Nyamuk\Pictures\PAG\indonesia inggris.PNG C:\Users\Nyamuk\Pictures\PAG\inggris indonesia.PNG


SOURCE KODE TOMBOL INDONESIA-INGGRIS
private void indingActionPerformed(java.awt.event.ActionEvent evt) {                                       
       if  (inding.isSelected()) jl1.setText("Masukan kata Indonesia"); else jl2.setText("Entry English Word");
       if  (inding.isSelected()) jl2.setText("Kata Inggrisnya"); else jl1.setText("Indonesian Word");  
       if  (inding.isSelected()) btSimpan.setText("Simpan"); else btSimpan.setText("Save");
       if  (inding.isSelected()) btHapus.setText("Hapus"); else btHapus.setText("Clear");
       if  (inding.isSelected()) btCari.setText("Cari"); else btCari.setText("Search");
       if  (inding.isSelected()) btLihatDaftar.setText("Lihat Daftar"); else btLihatDaftar.setText("See List");
   }                                 
Jika diklik tombol radio button Indonesia Inggris
SOURCE KODE INGGRIS INDONESIA
   private void ingindActionPerformed(java.awt.event.ActionEvent evt) {                                       
       if  (ingind.isSelected()) jl1.setText("Entry English Word"); else jl1.setText("Masukan kata Indonesia");
       if  (ingind.isSelected()) jl2.setText("Indoneisan word"); else jl1.setText("Entry English Word");
      if  (ingind.isSelected()) btSimpan.setText("Save"); else btSimpan.setText("Simpan");
      if  (ingind.isSelected()) btHapus.setText("Clear"); else btHapus.setText("Hapus");
       if  (ingind.isSelected()) btCari.setText("Search"); else btCari.setText("Cari");
       if  (ingind.isSelected()) btLihatDaftar.setText("See List"); else btCari.setText("Lihat Daftar");
   }            
Jika diklik tombol radio button Inggris -Indonesia                  


SOURCE KODE UNTUK TOMBOL SIMPAN/SAVE
   private void btSimpanActionPerformed(java.awt.event.ActionEvent evt) {                                         
default_hastabe_array();


       // TODO add your handling code here;
       if (Indonesia.isSelected()){
           String baru=new String(inputkata.getText().trim().toLowerCase());
           
           if(HT1.containsKey(baru)){
                JOptionPane.showMessageDialog(null,"Data "+inputkata.getText()+
                        " ; "+ outputkata.getText()+" Sudah ada di kamus");}
           else{String a=inputkata.getText();
           String b=outputkata.getText();
           HT1.put(a, b);
           HT2.put(b, a);       
           kata[Cckata][0]=a;
           kata[Cckata][1]=b;
           Cckata++;
           }   }        else{
       if (Inggris.isSelected()){
           String baru=new String(inputkata.getText().trim().toLowerCase());            
            if(HT2.containsKey(baru)){
                JOptionPane.showMessageDialog(null,"word "+inputkata.getText()+
                        " ; "+ outputkata.getText()+" has been add in Dictionary");} else
           {String a=inputkata.getText();       
String b=outputkata.getText();
       
       HT1.put(a, b);
       HT2.put(b, a);
       
       kata[Cckata][0]=b;
       kata[Cckata][1]=a;
       
       Cckata++;} } }     }
  SOURCE KODE TOMBOL LIHAT DAFTAR/ SEE LIST
       default_hastabe_array();
       textdaftar.setText("");
       if (lihat.getText().equals("Lihat daftar")) {
           for (int i=0; i<=Cckata-1; i++)  {
               textdaftar.append(kata[i][0]+" ; "+kata[i][1]+"\n");
           }
       }
       else if (lihat.getText().equals("See Dictionary"))  {
           for (int i=0; i<=Cckata-1; i++)
           {
               textdaftar.append(kata[i][1]+" ; "+kata[i][0]+"\n");
           } }}            
Untuk source kode search atau cari
default_hastabe_array();


       // TODO add your handling code here;
       if (Indonesia.isSelected()){
           String baru=new String(inputkata.getText().trim().toLowerCase());
           
           if(HT1.containsKey(baru)){
               outputkata.setText((String)HT1.get(baru));}
           else
           {
               outputkata.setText("Tidak di temukan");
           }
           }
       else
       {
       if (Inggris.isSelected()){
           String baru=new String(inputkata.getText().trim().toLowerCase());
           
            if(HT2.containsKey(baru)){
               outputkata.setText((String)HT2.get(baru));}
           else
           {
               outputkata.setText("Not Found");}}}}


source kode tombol exit atau keluar
System.exit(0);


Source kode hapus
  inputkata.setText("");
       outputkata.setText("");


hasil running
Kamus Indonesia-Inggris



Setelah di simpan/save maka data akan tersimpan, jika ingin menampikan hasil klik tombol lihat daftar/see list


Jika tidak ada
Lihat daftar kata dalam kamus(klik Lihat daftar)


Menambah kata( klik simpan/save)




Jika kata sudah ada dalam kamus