Popular Post

Archive for Maret 2017

Thread Dalam Java

By : Unknown
Class BOLA.
public class BOLA implements Runnable{
Form F;
  public BOLA(Form aThis) {
       F=aThis;
  }
   @Override
   public void run() {
      while (true) F.gambarkanbola();
   }  
}

Class KOTAK.
public class KOTAK implements Runnable{
   Form F;
public KOTAK(Form aThis) {
       F=aThis;
  }
   @Override
   public void run() {
       while (true) F.gambarkankotak();
   }  
}





FORM
import java.awt.Color;
import java.awt.Graphics;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Form extends javax.swing.JFrame {

   public Form() {
       initComponents();
       setTitle("Thread & Kotak");
   }
private void BolaStartActionPerformed(java.awt.event.ActionEvent evt) {                                          
       Ktr1 = new Thread(new BOLA(this));
       Ktr1.start();
   }                                         

   private void BolaStopActionPerformed(java.awt.event.ActionEvent evt) {                                         
       Ktr1.stop();
   }                                        

   private void KotakStartActionPerformed(java.awt.event.ActionEvent evt) {                                           
       Ktr2 = new Thread(new KOTAK(this));
       Ktr2.start();
   }                                          

   private void KotakStopActionPerformed(java.awt.event.ActionEvent evt) {                                          
       Ktr2.stop();
   }

Thread Ktr1;

   void gambarkanbola() {
       Graphics g = canvas1.getGraphics();
       int x = (int) (Math.random() * canvas1.getWidth());
       int y = (int) (Math.random() * canvas1.getHeight());
       canvas1.update(g);
       g.setColor(Color.red);
       g.fillOval(x, y, 30, 30);
       try {
           Ktr1.sleep(1000);
       } catch (InterruptedException ex) {
           Logger.getLogger(Form.class.getName()).log(Level.SEVERE, null, ex);
       }
   }

   Thread Ktr2;
   void gambarkankotak() {
       Graphics g = canvas1.getGraphics();
       int x = (int) (Math.random() * canvas1.getWidth());
       int y = (int) (Math.random() * canvas1.getHeight());
       canvas1.update(g);
       g.setColor(Color.blue);
       g.fillRect(y, x, 30, 30);
       try {
           Ktr2.sleep(1000);
       } catch (InterruptedException ex) {
           Logger.getLogger(Form.class.getName()).log(Level.SEVERE, null, ex);
       }
   }
}
RUNNING :
       

Program Java Kamus

By : Unknown
TUGAS 01
PEMROGAMAN ANTAR GRAFIS
PROGRAM KAMUS



Disusun oleh :
NAMA : Muhammad Fahrizal Farid (NIM : 141051002)


JURUSAN TEKNIK INFORMATIKA
FAKULTAS TEKNOLOGI INDUSTRI
INSTITUT SAINS & TEKNOLOGI AKPRIND
YOGYAKARTA
2015
import java.awt.LayoutManager;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Hashtable;
import javax.swing.JOptionPane;

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Fahri
*/
public class frame_tes extends javax.swing.JFrame {

   Hashtable Tabel1 = new Hashtable(); // untuk menyimpan kamus Indonesia-Inggris
   Hashtable Tabel2 = new Hashtable(); // untuk menyimpan kamus english-indonesia
   int Cckata = 100;
   String[][] daftar = new String[100][2];

   public frame_tes() {
       initComponents();
       setTitle("KAMUS INDONESIA --> INGGRIS");
       Tabel1.put("merah", "red");
       Tabel1.put("kucing", "cat");
       Tabel1.put("putih", "white");
       Tabel1.put("hitam", "black");
       Tabel1.put("air", "water");

       Tabel2.put("red", "merah");
       Tabel2.put("cat", "kucing");
       Tabel2.put("white", "putih");
       Tabel2.put("black", "hitam");
       Tabel2.put("water", "air");

   }

   /**
    * This method is called from within the constructor to initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is always
    * regenerated by the Form Editor.
    */
   @SuppressWarnings("unchecked")
   // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
   private void initComponents() {

       buttonGroup1 = new javax.swing.ButtonGroup();
       jPanel1 = new javax.swing.JPanel();
       lab1 = new javax.swing.JLabel();
       lab2 = new javax.swing.JLabel();
       input_kata = new javax.swing.JTextField();
       hasil = new javax.swing.JTextField();
       jLabel1 = new javax.swing.JLabel();
       jPanel2 = new javax.swing.JPanel();
       nyimpen = new javax.swing.JButton();
       lihdaftar = new javax.swing.JButton();
       jScrollPane1 = new javax.swing.JScrollPane();
       hasilarea = new javax.swing.JTextArea();
       jPanel3 = new javax.swing.JPanel();
       cari = new javax.swing.JButton();
       hapus = new javax.swing.JButton();
       keluar = new javax.swing.JButton();
       jPanel4 = new javax.swing.JPanel();
       jPanel5 = new javax.swing.JPanel();
       tombol_inggris = new javax.swing.JRadioButton();
       tombol_indonesia = new javax.swing.JRadioButton();
       jLabel3 = new javax.swing.JLabel();

       setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

       jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

       lab1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
       lab1.setText("Masukkan Kata Indonesia");

       lab2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
       lab2.setText("Kata Inggrisnya");

       input_kata.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
       input_kata.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               input_kataActionPerformed(evt);
           }
       });

       hasil.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               hasilActionPerformed(evt);
           }
       });

       javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
       jPanel1.setLayout(jPanel1Layout);
       jPanel1Layout.setHorizontalGroup(
           jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(jPanel1Layout.createSequentialGroup()
               .addContainerGap()
               .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                   .addComponent(lab1)
                   .addComponent(lab2))
               .addGap(18, 18, 18)
               .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                   .addGroup(jPanel1Layout.createSequentialGroup()
                       .addComponent(hasil, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)
                       .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                   .addGroup(jPanel1Layout.createSequentialGroup()
                       .addComponent(input_kata, javax.swing.GroupLayout.PREFERRED_SIZE, 225, javax.swing.GroupLayout.PREFERRED_SIZE)
                       .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 49, Short.MAX_VALUE)
                       .addComponent(jLabel1)
                       .addGap(18, 18, 18))))
       );
       jPanel1Layout.setVerticalGroup(
           jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(jPanel1Layout.createSequentialGroup()
               .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                   .addGroup(jPanel1Layout.createSequentialGroup()
                       .addContainerGap()
                       .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                           .addComponent(lab1)
                           .addComponent(input_kata, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                   .addGroup(jPanel1Layout.createSequentialGroup()
                       .addGap(28, 28, 28)
                       .addComponent(jLabel1)))
               .addGap(18, 18, 18)
               .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                   .addComponent(lab2)
                   .addComponent(hasil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
               .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
       );

       jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

       nyimpen.setText("Simpan");
       nyimpen.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               nyimpenActionPerformed(evt);
           }
       });

       lihdaftar.setText("Lihat Daftar");
       lihdaftar.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               lihdaftarActionPerformed(evt);
           }
       });

       hasilarea.setColumns(20);
       hasilarea.setFont(new java.awt.Font("Monospaced", 0, 14)); // NOI18N
       hasilarea.setRows(5);
       jScrollPane1.setViewportView(hasilarea);

       javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
       jPanel2.setLayout(jPanel2Layout);
       jPanel2Layout.setHorizontalGroup(
           jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(jPanel2Layout.createSequentialGroup()
               .addContainerGap()
               .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                   .addGroup(jPanel2Layout.createSequentialGroup()
                       .addComponent(nyimpen)
                       .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                       .addComponent(lihdaftar))
                   .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 196, javax.swing.GroupLayout.PREFERRED_SIZE))
               .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
       );
       jPanel2Layout.setVerticalGroup(
           jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(jPanel2Layout.createSequentialGroup()
               .addGap(22, 22, 22)
               .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                   .addComponent(nyimpen)
                   .addComponent(lihdaftar))
               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
               .addComponent(jScrollPane1)
               .addContainerGap())
       );

       jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

       cari.setText("Cari");
       cari.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               cariActionPerformed(evt);
           }
       });

       hapus.setText("Hapus");
       hapus.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               hapusActionPerformed(evt);
           }
       });

       keluar.setText("Keluar");
       keluar.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               keluarActionPerformed(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()
               .addComponent(cari)
               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
               .addComponent(hapus)
               .addGap(18, 18, 18)
               .addComponent(keluar)
               .addGap(6, 6, 6))
       );
       jPanel3Layout.setVerticalGroup(
           jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
               .addContainerGap()
               .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                   .addComponent(cari, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                   .addGroup(jPanel3Layout.createSequentialGroup()
                       .addGap(0, 3, Short.MAX_VALUE)
                       .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                           .addComponent(hapus)
                           .addComponent(keluar))))
               .addContainerGap())
       );

       jPanel4.setBackground(new java.awt.Color(204, 204, 204));
       jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Mode Kamus", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N
       jPanel4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

       jPanel5.setBackground(new java.awt.Color(204, 204, 204));

       tombol_inggris.setBackground(new java.awt.Color(0, 0, 0));
       buttonGroup1.add(tombol_inggris);
       tombol_inggris.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
       tombol_inggris.setText("Inggris-Indonesia");
       tombol_inggris.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               tombol_inggrisActionPerformed(evt);
           }
       });

       tombol_indonesia.setBackground(new java.awt.Color(0, 0, 0));
       buttonGroup1.add(tombol_indonesia);
       tombol_indonesia.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
       tombol_indonesia.setSelected(true);
       tombol_indonesia.setText("Indonesia-Inggris");
       tombol_indonesia.setAutoscrolls(true);
       tombol_indonesia.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(java.awt.event.ActionEvent evt) {
               tombol_indonesiaActionPerformed(evt);
           }
       });

       javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
       jPanel5.setLayout(jPanel5Layout);
       jPanel5Layout.setHorizontalGroup(
           jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
               .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
               .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                   .addComponent(tombol_inggris)
                   .addComponent(tombol_indonesia))
               .addGap(30, 30, 30))
       );
       jPanel5Layout.setVerticalGroup(
           jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
               .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
               .addComponent(tombol_indonesia)
               .addGap(40, 40, 40)
               .addComponent(tombol_inggris)
               .addContainerGap())
       );

       javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
       jPanel4.setLayout(jPanel4Layout);
       jPanel4Layout.setHorizontalGroup(
           jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addComponent(jPanel5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
       );
       jPanel4Layout.setVerticalGroup(
           jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addComponent(jPanel5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
       );

       javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
       getContentPane().setLayout(layout);
       layout.setHorizontalGroup(
           layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(layout.createSequentialGroup()
               .addContainerGap()
               .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                   .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                   .addGroup(layout.createSequentialGroup()
                       .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                       .addGap(18, 18, 18)
                       .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                           .addGroup(layout.createSequentialGroup()
                               .addGap(0, 0, Short.MAX_VALUE)
                               .addComponent(jLabel3))
                           .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                               .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                               .addGap(16, 16, 16))
                           .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
               .addContainerGap())
       );
       layout.setVerticalGroup(
           layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
           .addGroup(layout.createSequentialGroup()
               .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
               .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                   .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                   .addGroup(layout.createSequentialGroup()
                       .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                       .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                       .addComponent(jLabel3)
                       .addGap(20, 20, 20)
                       .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                       .addGap(0, 0, Short.MAX_VALUE)))
               .addContainerGap())
       );

       pack();
   }// </editor-fold>                        

   private void input_kataActionPerformed(java.awt.event.ActionEvent evt) {                                           

   }                                          

   private void hasilActionPerformed(java.awt.event.ActionEvent evt) {                                      
       // TODO add your handling code here:
   }                                     

   private void keluarActionPerformed(java.awt.event.ActionEvent evt) {                                       
       System.exit(0);
   }                                      

   private void cariActionPerformed(java.awt.event.ActionEvent evt) {                                     
       try{
       if (tombol_indonesia.isSelected()) {
           if (input_kata.getText().equals("")) {
               JOptionPane.showMessageDialog(null, "Masukkan Salah \n"
                       + "Tidak Ada Kata yang Ditemukan");
           } else if ((Tabel1.containsKey(input_kata.getText()))) {
               hasil.setText((String) Tabel1.get(input_kata.getText()));
           } else {
               hasil.setText("Kata Tidak Ditemukan");
           }
       } else if (tombol_inggris.isSelected()) {
           if (input_kata.getText().equals("")) {
               JOptionPane.showMessageDialog(null, "Wrong Input \n"
                       + "Word Not Found");
           } else if (Tabel2.containsKey(input_kata.getText())) {
               hasil.setText((String) Tabel2.get(input_kata.getText()));
           }else{
               hasil.setText("Not Found !!");
           }
       }
       }
       catch(Exception e){
           System.out.println("Error Cari --> "+e);
       }
   }                                    

   private void hapusActionPerformed(java.awt.event.ActionEvent evt) {                                      
       input_kata.setText(null);
       hasil.setText(null);
       hasilarea.setText(null);
   }                                     

   private void tombol_indonesiaActionPerformed(java.awt.event.ActionEvent evt) {                                                 
       if (tombol_indonesia.isSelected()) {
           lihdaftar.setText("Lihat Kamus");
           nyimpen.setText("Simpan");
           cari.setText("Cari");
           hapus.setText("Hapus");
           keluar.setText("Keluar");
           setTitle("KAMUS INDONESIA --> INGRRIS");
           lab1.setText("Masukkan Kata Indonesia");
           lab2.setText("Kata Inggrisnya");
       }
   }                                                

   private void lihdaftarActionPerformed(java.awt.event.ActionEvent evt) {                                          
       hasilarea.setText(null);
       Enumeration indo = Tabel1.keys(); //x
       Enumeration ing = Tabel2.keys();
       try{
       if (tombol_indonesia.isSelected()) {
           while (indo.hasMoreElements()) {
               String y = indo.nextElement().toString();
               hasilarea.append(y + ", " + Tabel1.get(y) + "\n");
           }
       } else {

           while (ing.hasMoreElements()) {
               String yy = ing.nextElement().toString();
               hasilarea.append(yy + ", " + Tabel2.get(yy) + "\n");
           }
       }
       }
       catch (Exception e){
           System.out.println("Erro Lihat Daftar --> "+e);
       }


   }                                         

   private void nyimpenActionPerformed(java.awt.event.ActionEvent evt) {                                        
      try{
       if (tombol_indonesia.isSelected()) {
           if (Tabel1.containsKey(input_kata.getText())) {
               hasil.setText((String) Tabel1.get(input_kata.getText()));
               JOptionPane.showMessageDialog(null, "Kata: " + input_kata.getText() + " " + hasil.getText() + " " + " Sudah Ada Di Kamus !!");
           } else {
               String satu = input_kata.getText();
               Tabel1.put(satu, hasil.getText());
               Tabel2.put(hasil.getText(), satu);
               hasilarea.append(satu + ", " + hasil.getText());
           }

       } else if (Tabel2.containsKey(input_kata.getText())) {
           hasil.setText((String) Tabel2.get(input_kata.getText()));
           JOptionPane.showMessageDialog(null, input_kata.getText() + " " + hasil.getText() + " " + "The Word You Have Entry is Already Exist !!");
       } else {
           String dua = input_kata.getText();
           Tabel2.put(dua, hasil.getText());
           Tabel1.put(hasil.getText(), dua);
           hasilarea.append(dua + ", " + hasil.getText());
       }
      }catch(Exception e){
          System.out.println("Error Simpan --> "+e);
      }


   }                                       

   private void tombol_inggrisActionPerformed(java.awt.event.ActionEvent evt) {                                               
       if (tombol_inggris.isSelected()) {
           nyimpen.setText("Save");
           cari.setText("Search");
           hapus.setText("Clear");
           keluar.setText("Exit");
           lihdaftar.setText("See Directory");
           setTitle("ENGLISH WORD --> INDONESIAN");
           lab1.setText("Entry English Word");
           lab2.setText("Indonesian Word");
       }
   }                                              

   /**
    * @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(frame_tes.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
       } catch (InstantiationException ex) {
           java.util.logging.Logger.getLogger(frame_tes.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
       } catch (IllegalAccessException ex) {
           java.util.logging.Logger.getLogger(frame_tes.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
       } catch (javax.swing.UnsupportedLookAndFeelException ex) {
           java.util.logging.Logger.getLogger(frame_tes.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 frame_tes().setVisible(true);
           }
       });
   }
   // Variables declaration - do not modify                     
   private javax.swing.ButtonGroup buttonGroup1;
   private javax.swing.JButton cari;
   private javax.swing.JButton hapus;
   private javax.swing.JTextField hasil;
   private javax.swing.JTextArea hasilarea;
   private javax.swing.JTextField input_kata;
   private javax.swing.JLabel jLabel1;
   private javax.swing.JLabel jLabel3;
   private javax.swing.JPanel jPanel1;
   private javax.swing.JPanel jPanel2;
   private javax.swing.JPanel jPanel3;
   private javax.swing.JPanel jPanel4;
   private javax.swing.JPanel jPanel5;
   private javax.swing.JScrollPane jScrollPane1;
   private javax.swing.JButton keluar;
   private javax.swing.JLabel lab1;
   private javax.swing.JLabel lab2;
   private javax.swing.JButton lihdaftar;
   private javax.swing.JButton nyimpen;
   private javax.swing.JRadioButton tombol_indonesia;
   private javax.swing.JRadioButton tombol_inggris;                }
Hasil Running Program :
  1. Indonesia-Inggris.
  1. Validasi, dimana jika data yang dimasukkan masih kosong dan user sudah menekan tombol cari.
  

  1. Pencarian Kata.
  

  1. Menyimpan Kata & Lihat daftar.


  1. Inggris-Indonesia.
  1. Validasi, dimana jika data yang dimasukkan masih kosong dan user sudah menekan tombol cari.

  1. Pencarian Kata.

  1. Menyimpan kata dan melihat daftar.

- Copyright © Informatika - Date A Live - Powered by Blogger - Designed by Johanes Djogan -