Show date and Clock in java Frame

View previous topic View next topic Go down

Show date and Clock in java Frame

Post by Saiful on Wed Jul 28, 2010 1:49 pm

Here is code For Show date and time in JFrame:

Code:

import java.awt.Font;
import java.text.DateFormat;
import java.text.SimpleDateFormat;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;






public class Date_Time extends JFrame{

    public JPanel show_date_time = new JPanel();
   
    public JLabel date = new JLabel("Date");
    public JLabel time = new JLabel("Time");
    public JLabel show_time = new JLabel("Show Time");
    public JLabel Show_date = new JLabel("Show Date");

    DateFormat dateFormat2 = new SimpleDateFormat("h:mm:ss a");
    java.util.Date date2;


    public Date_Time(){
        this.setSize(1030, 735);
       
        this.setResizable(false);

        getContentPane().add(Show_Time_date());

       
    }
   
   
    public JPanel Show_Time_date(){
       
        show_date_time.setLayout(null);
        show_date_time.setBounds(0,100, 1030, 635);
       
       
        Font f;
        f = new Font("SansSerif", Font.PLAIN, 15);

        date.setBounds(50, 100, 100, 30);
        date.setFont(f);
        show_date_time.add(date);

        time.setBounds(700,100,100,30);
        time.setFont(f);
        show_date_time.add(time);

        DateFormat dateFormat = new SimpleDateFormat("EEEEEEEEE: dd MMMMMMMMM, yyyy.");
        java.util.Date date = new java.util.Date();
        String dateTime = dateFormat.format(date);

        Show_date = new JLabel(dateTime);
        Show_date.setBounds(150, 100, 200, 30);
        Show_date.setFont(f);
        show_date_time.add(Show_date);   
       
        show_time= new JLabel("");
        updateDateTime();
        show_time.setBounds(800,100,200,30);
        show_time.setFont(f);
        show_date_time.add(show_time);


   
        return show_date_time;
    }
    /**
    * @param args
    */
    public static void main(String[] args) {
       
        Date_Time Main_win=new Date_Time();
        Main_win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Main_win.setVisible(true);

    }
    public void updateDateTime()
    {
    Thread th = new Thread(new Runnable()
        {
        public void run()
            {
            while(true)
                {
                date2 = new java.util.Date();
                String dateTime = dateFormat2.format(date2);
                show_time.setText(dateTime);
                show_time.updateUI();
                }
            }
        });
    th.start();
    }


}



Last edited by Saiful on Fri Jul 30, 2010 11:55 pm; edited 1 time in total
avatar
Saiful
Beta Release
Beta Release

Course(s) :
  • BIT

Blood Group : A+
Posts : 50
Points : 88

View user profile

Back to top Go down

Re: Show date and Clock in java Frame

Post by BIT0104-ANIK on Thu Jul 29, 2010 4:57 pm

Saiful wrote:........ JFream:

ki jinis mamu?

_________________________________________________________________
Buddhong shoronogocchami..
dhommong shoronogocchami..
shonghong shoronogocchami..
Jogoter sokol prani.. shukhi hok.
avatar
BIT0104-ANIK
Administrator
Administrator

Course(s) :
  • BIT

Blood Group : O+
Posts : 423
Points : 699

View user profile http://anikstech.blogspot.com

Back to top Go down

Re: Show date and Clock in java Frame

Post by BIT0122-Amit on Thu Jul 29, 2010 5:38 pm

BIT0104-ANIK wrote:
Saiful wrote:........ JFream:

ki jinis mamu?

wahahahah Very Happy I had to edit the topic title Razz

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

Re: Show date and Clock in java Frame

Post by BIT0112-Rokon on Thu Jul 29, 2010 8:34 pm

BIT0104-ANIK wrote:
Saiful wrote:........ JFream:

ki jinis mamu?


darun moja pailam...

secondly ai code Java convention maintain kore nai...
akta jinis sobai remind kore dei.. java convention and coding standard onek important issue..
at least career a aitar impact onek beshi...
interview te dui line code likhte dile tara coding standard and convention kheyal korbe...
ami nijeo age aita somporke aware cilam na..
but akhon chesta kori.. convention and standard maintain korte.......

_________________________________________________________________


Code Explosion Blog | Code Explosion Wiki | The Rokonoid | নির্ঝরিণী
avatar
BIT0112-Rokon
Programmer
Programmer

Course(s) :
  • BIT

Blood Group : O+
Posts : 673
Points : 1269

View user profile http://blog.codexplo.org

Back to top Go down

Re: Show date and Clock in java Frame

Post by BIT0122-Amit on Thu Jul 29, 2010 11:09 pm

bit0112-rokon wrote:
BIT0104-ANIK wrote:
Saiful wrote:........ JFream:

ki jinis mamu?


darun moja pailam...

secondly ai code Java convention maintain kore nai...
akta jinis sobai remind kore dei.. java convention and coding standard onek important issue..
at least career a aitar impact onek beshi...
interview te dui line code likhte dile tara coding standard and convention kheyal korbe...
ami nijeo age aita somporke aware cilam na..
but akhon chesta kori.. convention and standard maintain korte.......

tui to khali eita dekhtesish Very Happy oy class e ja korse ajke eita niye .. .. Very Happy
But ja dise, vala hoise Very Happy

Tui coding convention follow kore eitar standardized form de Very Happy amra shikhte agrohi Very Happy

_________________________________________________________________
Adminship / Moderatorship is not about power, it is about Responsibility.

|About me|My Blog|
avatar
BIT0122-Amit
Founder
Founder

Course(s) :
  • BIT

Blood Group : O+
Posts : 4187
Points : 6605

View user profile http://iitdu.forumsmotion.com

Back to top Go down

Re: Show date and Clock in java Frame

Post by BIT0129-Tabassum on Fri Jul 30, 2010 4:20 am

lolzzzzzzzz very very funny
class a Jframe darun uccharon dekhe amra nijerai vasha harie felesilam Razz

_________________________________________________________________
মানুষ তার স্বপ্নের সমান বড়
avatar
BIT0129-Tabassum
Global Moderator
Global Moderator

Course(s) :
  • BIT

Blood Group : A+
Posts : 1496
Points : 2298

View user profile http://probe-tabassum.blogspot.com

Back to top Go down

Re: Show date and Clock in java Frame

Post by BIT0112-Rokon on Fri Jul 30, 2010 4:33 am

class a ki hoicilo..?

_________________________________________________________________


Code Explosion Blog | Code Explosion Wiki | The Rokonoid | নির্ঝরিণী
avatar
BIT0112-Rokon
Programmer
Programmer

Course(s) :
  • BIT

Blood Group : O+
Posts : 673
Points : 1269

View user profile http://blog.codexplo.org

Back to top Go down

Re: Show date and Clock in java Frame

Post by BIT0112-Rokon on Fri Jul 30, 2010 5:18 am

atcha .. java coding standard niye akta tutorial lekhbo ....

_________________________________________________________________


Code Explosion Blog | Code Explosion Wiki | The Rokonoid | নির্ঝরিণী
avatar
BIT0112-Rokon
Programmer
Programmer

Course(s) :
  • BIT

Blood Group : O+
Posts : 673
Points : 1269

View user profile http://blog.codexplo.org

Back to top Go down

Re: Show date and Clock in java Frame

Post by Saiful on Fri Jul 30, 2010 11:58 pm

Hmm ami Ki?
avatar
Saiful
Beta Release
Beta Release

Course(s) :
  • BIT

Blood Group : A+
Posts : 50
Points : 88

View user profile

Back to top Go down

Re: Show date and Clock in java Frame

Post by Saiful on Fri Jul 30, 2010 11:59 pm

Dil e khub balo hoy baby
avatar
Saiful
Beta Release
Beta Release

Course(s) :
  • BIT

Blood Group : A+
Posts : 50
Points : 88

View user profile

Back to top Go down

Re: Show date and Clock in java Frame

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum