Share on Google+Share on Google+

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

think u for help me ..

Ads

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
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 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
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 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 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 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 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
Tutorials   
Java Spring Hibernate Struts Training What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? neo4j-server.properties file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code

Ads

 
Advertisement null

Ads