Back-End Programming Exam  >  Back-End Programming Videos  >  Java Programming Fundamentals: For Beginners (in Hindi)  >  Lecture 56 How to display digital clock in an Applet in JavaHindi

Lecture 56 How to display digital clock in an Applet in JavaHindi Video Lecture | Java Programming Fundamentals: For Beginners (in Hindi) - Back-End Programming

75 videos

FAQs on Lecture 56 How to display digital clock in an Applet in JavaHindi Video Lecture - Java Programming Fundamentals: For Beginners (in Hindi) - Back-End Programming

1. क्या एपलेट में जावा में डिजिटल घड़ी कैसे दिखाई जा सकती है?
उत्तर. डिजिटल घड़ी को एपलेट में जावा में दिखाने के लिए, आपको एपलेट क्लास को वापसी करने और एपलेट के पैनल पर समय को प्रिंट करने के लिए एपलेट के paint() विधि में कुछ कोड जोड़ना होगा। यहां आप कोड स्निपेट है: public class DigitalClock extends Applet { @Override public void init() { setSize(300, 300); } @Override public void paint(Graphics g) { // Get the current time DateFormat dateFormat = new SimpleDateFormat("hh:mm:ss"); Date date = new Date(); String currentTime = dateFormat.format(date); // Display the current time on the applet's panel g.drawString(currentTime, 20, 20); } }
2. क्या एपलेट में जावा में डिजिटल घड़ी को रीफ्रेश करना क्यों जरूरी है?
उत्तर. एपलेट में जावा में डिजिटल घड़ी को रीफ्रेश करना जरूरी है ताकि घड़ी का समय नया हो और अद्यतित हो। यदि आप रीफ्रेश नहीं करेंगे, तो घड़ी का समय स्थायी होगा और नया समय प्रदर्शित नहीं होगा। एपलेट क्लास के paint() विधि में घड़ी को रीफ्रेश करने के लिए तारीख और समय को प्राप्त करने और नया समय प्रदर्शित करने के लिए एक नया paint() कॉल करना चाहिए।
3. क्या एपलेट में जावा में डिजिटल घड़ी में रंग बदलाया जा सकता है?
उत्तर. हां, एपलेट में जावा में डिजिटल घड़ी में रंग बदला जा सकता है। आप घड़ी के समय को प्रदर्शित करने के लिए setColor() विधि का उपयोग करके घड़ी के टेक्स्ट के लिए एक नया रंग सेट कर सकते हैं। यहां एक उदाहरण है: g.setColor(Color.RED); g.drawString(currentTime, 20, 20);
4. क्या एपलेट में जावा में डिजिटल घड़ी में तारीख भी प्रदर्शित की जा सकती है?
उत्तर. हां, एपलेट में जावा में डिजिटल घड़ी में तारीख भी प्रदर्शित की जा सकती है। आप एपलेट क्लास में तारीख और समय दोनों को प्राप्त करने के लिए DateFormat का उपयोग कर सकते हैं। यहां एक उदाहरण है: DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss"); Date date = new Date(); String currentDateTime = dateFormat.format(date); g.drawString(currentDateTime, 20, 20);
5. क्या एपलेट में जावा में डिजिटल घड़ी में घड़ी की दिशा बदली जा सकती है?
उत्तर. हां, एपलेट में जावा में डिजिटल घड़ी में घड़ी की दिशा बदली जा सकती है। आप घड़ी को प्रदर्शित करने के लिए Graphics2D का उपयोग करके घड़ी की दिशा को सेट कर सकते हैं। निम्नलिखित कोड स्निपेट में, समय को प्राप्त करने के लिए एक Calendar बनाएं, घड़ी की दिशा को सेट करें और घड़ी को प्रदर्शित करने के लिए Graphics2D का उपयोग करें: Calendar calendar = Calendar.getInstance(); int hour = calendar.get(Calendar.HOUR); int minute = calendar.get(Calendar.MINUTE); int second = calendar.get(Calendar.SECOND); Graphics2D g2d = (Graphics2D) g; g2d.rotate(Math.toRadians(second * 6), 150, 150); g2d.drawString(currentTime, 20, 20);
75 videos
Explore Courses for Back-End Programming exam
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

mock tests for examination

,

MCQs

,

Objective type Questions

,

past year papers

,

Semester Notes

,

pdf

,

practice quizzes

,

Lecture 56 How to display digital clock in an Applet in JavaHindi Video Lecture | Java Programming Fundamentals: For Beginners (in Hindi) - Back-End Programming

,

Free

,

ppt

,

Lecture 56 How to display digital clock in an Applet in JavaHindi Video Lecture | Java Programming Fundamentals: For Beginners (in Hindi) - Back-End Programming

,

Previous Year Questions with Solutions

,

Summary

,

Extra Questions

,

Important questions

,

Exam

,

video lectures

,

shortcuts and tricks

,

study material

,

Viva Questions

,

Sample Paper

,

Lecture 56 How to display digital clock in an Applet in JavaHindi Video Lecture | Java Programming Fundamentals: For Beginners (in Hindi) - Back-End Programming

;