Minggu, 30 September 2018

Jam Digital

Berikut hasil dan source code-nya.




Executor

 /**  
  * Write a description of class Executor here.  
  *  
  * @author (Ismail)  
  * @version (01102018)  
  */  
 public class Executor  
 {  
   public static void main(String[]args)  
   {  
     new Executor();  
   }  
   public Executor()  
   {  
     new waktu();  
   }  
 }  


Waktu

 /**  
  * Write a description of class waktu here.  
  *  
  * @author (Ismail)  
  * @version (01102018)  
  */  
 import javax.swing.*;  
 import java.awt.*;  
 import java.awt.event.*;  
 import java.util.Calendar;  
 public class waktu extends JFrame  
 {  
   private static final long serialVersionUID = 1L;  
   JTextField timeF;  
   JPanel panel;  
   public waktu()  
   {  
     super("Java Clock by Ismail Arifin");  
     setSize(500,200);  
     setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
     setVisible(true);  
     setResizable(true);  
     setLocationRelativeTo(null);  
     panel = new JPanel();  
     panel.setLayout(new FlowLayout());  
     timeF = new JTextField(10);  
     timeF.setEditable(false);  
     timeF.setFont(new Font("Arial",Font.PLAIN,50));  
     panel.add(timeF);  
     add(panel);  
     Timer t = new Timer(1000,new Listener());  
     t.start();  
   }  
   class Listener implements ActionListener  
   {  
     public void actionPerformed(ActionEvent e)  
     {  
       Calendar rightNow = Calendar.getInstance();  
       int hour = rightNow.get(Calendar.HOUR_OF_DAY);  
       int min = rightNow.get(Calendar.MINUTE);  
       int sec = rightNow.get(Calendar.SECOND);  
       timeF.setText(hour+":"+min+":"+sec);  
     }  
   }  
 }  

Tidak ada komentar:

Posting Komentar

EAS PBO B

1. Rancangan interface image editor. 2. Class diagram dari image editor yang akan dibuat terdiri atas 10 class seperti berikut. ...