Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners how can create clock baisc in java
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


didar sham
how can create clock baisc in java
1 Answer(s)      3 years and 6 months ago
Posted in : Java Beginners


think u for help me ..


Advertisement
View Answers

April 27, 2011 at 11:06 AM


import java.awt.*;
import java.util.*; 
import javax.swing.*;
import java.awt.event.*;
import javax.swing.event.*;

public class DisplayClock extends JFrame {
     DisplayClock() {
        final JLabel timeField = new JLabel();
        timeField.setFont(new Font("sansserif", Font.PLAIN, 20));

        Container content = this.getContentPane();
        content.setLayout(new FlowLayout());
        content.add(timeField); 

        setTitle("Clock");
        setSize(100,70);

        javax.swing.Timer t = new javax.swing.Timer(1000,new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Calendar cal = new GregorianCalendar();
            String hour = String.valueOf(cal.get(Calendar.HOUR));
            String minute = String.valueOf(cal.get(Calendar.MINUTE));
            String second = String.valueOf(cal.get(Calendar.SECOND));
            timeField.setText("" + hour + ":" + minute + ":" + second);
            }
        });
        t.start(); 
    }
    public static void main(String[] args) {
        JFrame clock = new DisplayClock();
        clock.setVisible(true);
    }
}


Related Tutorials/Questions & Answers:
how can create clock baisc in java
how can create clock baisc in java   think u for help me ..  ...()); content.add(timeField); setTitle("Clock"); setSize(100,70...) { JFrame clock = new DisplayClock(); clock.setVisible(true
how can create clock baisc in java
how can create clock baisc in java   think u for help me ..  ...()); content.add(timeField); setTitle("Clock"); setSize(100,70...) { JFrame clock = new DisplayClock(); clock.setVisible(true
Advertisements
how can create clock baisc in java
how can create clock baisc in java   think u for help me ..  ...()); content.add(timeField); setTitle("Clock"); setSize(100,70...) { JFrame clock = new DisplayClock(); clock.setVisible(true
how we can create website through java
how we can create website through java  Dear actually i wanna ask query about creation of website through java then how we can create web site through java plz help me..........i have already a web site ....specially for premium
how can create album in java by using Stack ....
how can create album in java by using Stack ....  hi all , if i press push button put the image to the stack , and when i press pop button remove the image ..??? please help me please
how can create a jar file - Java Beginners
how can create a jar file  plz any one help me which file can i create the jar file plz give exact command  Hi The basic format... that you want to create a JAR file. * The f option indicates that you want
Clock Applet in Java
Java - Clock Applet in Java       Introduction Here is a sample of running clock provided by the java applet to illustrate how to use the clock in an applet. This program shows
we can create our own header file in java?n how to create?
we can create our own header file in java?n how to create?  we can create our own header file in java?n how to create
how can i create a data grid - Java Beginners
how can i create a data grid  Nice to ur respose...thnks all of u plz help me i want make a datagrid but i have no idea about this how can i create datagrid. and how can i connect to the database plz help me give
how to build a colorful clock in JSP without using Flash.
how to build a colorful clock in JSP without using Flash.  I have to make a colorful clock using java programming or some API in a JSP page. Please send me a code for it as soon as possible
Analog clock
Analog clock  how to develope analog clock using java
How we can create a table through procedure ?
How we can create a table through procedure ?  How we can create a table through procedure
How to display mysql database records as per clock timing?
How to display mysql database records as per clock timing?  I want to display database records as per clock timing
how can i create a discussion forum?
how can i create a discussion forum?  how can i create a discussion forum for my e- mentoring site for women which can be used by a registered user only. i am using jsp and servlets and i am working with netbeans 6.8.
How can I create sessionfactory in Hibernate?
How can I create sessionfactory in Hibernate?  HELLO, How can I create sessionfactory in Hibernate? If you can explain me with example that would be great. THANKS..   Dear Friend, Here is an Example of creating
How to create a class in java
How to create a class in java  I am a beginner in programming and tried to learn how to do programming in Java. Friends please explain how can I create a class in Java
java code digital clock - Java Beginners
java code digital clock  hello can you share or give me a code...://www.roseindia.net/java/example/java/applet/ClockApplet.shtml Thanks  ohhh i forget its a java program and it is using looping can you give me
how to create notepad in java
how to create notepad in java  how to create notepad in java
How to Create Keyboard in JAVA
How to Create Keyboard in JAVA  please help me to create On-Screen Keyboard with java and please give me an another idia to make it ..............iam waiting for your help ,think u so much
How to create charts in Java?
How to create charts in Java?  Is there any example of creating charts and graphs in Java? thanks   Hi, check the tutorial: Chart & Graphs Tutorials in Java Thanks
How can we create a database using PHP and mysql?
How can we create a database using PHP and mysql?  How can we create a database using PHP and mysql
how to create interfaces in java
how to create interfaces in java  HI, Here is my code public interface validateInfo { public void validate(String empcode, String password); } class updateInfo implements validateInfo { public void update() { //code
how to create reports in swing java?
how to create reports in swing java?  how to create reports in swing java
How to create first program in Java?
How to create first program in Java?  Hi, I am new in Java programming. Tell me How to create first program in Java? Thanks   Hi, Read more at First Java Program. Thanks
how can i create a mysql database to connect to this code - JDBC
how can i create a mysql database to connect to this code  i need...(Exception e){} } else{ System.exit(0); } } }); tp.addTab("Create Account",panel... is: bankdata CREATE TABLE `bankdata
how can i create a mysql database to connect to this code - JDBC
how can i create a mysql database to connect to this code  i need help creating a mysql database for this code. code is import java.awt....(Exception e){} } else{ System.exit(0); } } }); tp.addTab("Create Account",panel
How can I learn Java?
How can I learn Java?  Hi, I have just completed a course in HTML... programming. How can I learn Java? in shortest possible time. I mean I just want to begin... are the best ways to learn Java for a beginner? Thanks   Hi, You can
how to create executable - Java Beginners
how to create executable  How do i create a executable file from a java file thnks in adv...!  Hi Friend, Try the following code: import java.io.*; import java.util.jar.*; public class CreateExe { public
how create package of this java code
how create package of this java code  Hi,i have email code in java which is working fine with out making package but when i want to make package of this code its stop working.Its showing exception while I execute it.I have to use
how create package of this java code
how create package of this java code  Hi,i have email code in java which is working fine with out making package but when i want to make package of this code its stop working.Its showing exception while I execute it.I have to use
java how to create visual swing editor
java how to create visual swing editor   How do I create a visual swing designer in java ?Meaning that I can "draw" a button,a JTextArea from within my designer program . I just need some basics . I've got no idea how to start
Advertisements
 

 

 

DMCA.com