Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Java
You last visited: Today at 13:21

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Analoge Uhr in GUI | gebe 73e*g

Discussion on Analoge Uhr in GUI | gebe 73e*g within the Java forum part of the Coders Den category.

Reply
 
Old   #1


 
_ᴋush#'s Avatar
 
elite*gold: 356
Join Date: Jul 2011
Posts: 1,295
Received Thanks: 108
Analoge Uhr in GUI | gebe 73e*g

Hey Leute!

Ich hab im Internet gesucht und gesucht.. aber ich finde es einfach nicht.

brauche einfach eine große analoge Uhr mit Sekundenanzeige.

Natürlich in einer GUI als .class Datei.

Würde 73e*g bieten!

Wär super, wenn ihr mir sowas programmieren könntet
(dauert ja nicht lange oder?)

Gruß,
kush
_ᴋush# is offline  
Old 10/27/2015, 21:44   #2
 
Belur's Avatar
 
elite*gold: 0
Join Date: Jul 2009
Posts: 3,441
Received Thanks: 1,473
Also wenn ich nach "java analog clock" google, gibts da mehrere fertige Lösungen.

Hier mal eine:
Belur is offline  
Old 10/28/2015, 07:59   #3


 
_ᴋush#'s Avatar
 
elite*gold: 356
Join Date: Jul 2011
Posts: 1,295
Received Thanks: 108
Sorry, hab mich vertan ich meine eine digitale Uhr und da finde ich nur .java files..
_ᴋush# is offline  
Old 10/28/2015, 09:25   #4
 
elite*gold: 0
Join Date: Jul 2009
Posts: 211
Received Thanks: 137
Soll die eine einfache Anzeige haben oder eine siebensegment Anzeige?
JavaFX oder Swing?
Mysthik is offline  
Old 10/28/2015, 11:25   #5


 
_ᴋush#'s Avatar
 
elite*gold: 356
Join Date: Jul 2011
Posts: 1,295
Received Thanks: 108
JavaFX und eine einfache Anzeige

Edit: Hat sich erledigt. Habe einen Code gefunden, war zu blöd zu suchen

Code:
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Calendar;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.Timer;
import javax.swing.WindowConstants;

public class SimpleDigitalClock {

    public static void main(String[] args) {

        JFrame f = new JFrame();
        f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        DigitalClock myClock = new DigitalClock();
        f.add(myClock);
        f.pack();
        f.setVisible(true);
    }

    static class DigitalClock extends JPanel {

        String stringTime;
        int hour, minute, second;

        String correctionHour = "";
        String correctionMinute = "";
        String correctionSecond = "";

        public void setStringTime(String xyz) {
            this.stringTime = xyz;
        }

        public int findMinimumBetweenTwoNumbers(int a, int b) {
            return (a <= b) ? a : b;
        }

        DigitalClock() {

            Timer t1 = new Timer(1000, new ActionListener() {
                public void actionPerformed(ActionEvent e) {

                    repaint();
                }
            });
            t1.start();
        }

        @Override
        public void paintComponent(Graphics g) {
            super.paintComponent(g);

            Calendar now = Calendar.getInstance();
            hour = now.get(Calendar.HOUR_OF_DAY);
            minute = now.get(Calendar.MINUTE);
            second = now.get(Calendar.SECOND);

            if (hour < 10) {
                this.correctionHour = "0";
            }
            if (hour >= 10) {
                this.correctionHour = "";
            }

            if (minute < 10) {
                this.correctionMinute = "0";
            }
            if (minute >= 10) {
                this.correctionMinute = "";
            }

            if (second < 10) {
                this.correctionSecond = "0";
            }
            if (second >= 10) {
                this.correctionSecond = "";
            }
            setStringTime(correctionHour + hour + ":" + correctionMinute+ minute + ":" + correctionSecond + second);
            g.setColor(Color.BLACK);
            int length = findMinimumBetweenTwoNumbers(this.getWidth(),this.getHeight());
            Font myFont = new Font("SansSerif", Font.PLAIN, length / 5);
            g.setFont(myFont);
            g.drawString(stringTime, (int) length/6, length/2);

        }

        @Override
        public Dimension getPreferredSize() {
            return new Dimension(200, 200);
        }

    }

}
Der Code btw.
_ᴋush# is offline  
Reply


Similar Threads Similar Threads
[Buying] Suche mind. 1€ Paysafecard (1-Code) / Gebe 110 Elitegold, gebe first.
07/01/2014 - elite*gold Trading - 7 Replies
Titel Steht.
[Buying] Suche mind. 1€ Paysafecard (1-Code) / Gebe 30 Elitegold, gebe first.
06/28/2014 - elite*gold Trading - 2 Replies
Bitte per Nachricht schreiben
[Trading] suche League of legends acc Euw // Gebe Gebe Nostale (DE) Server 2 gold
03/26/2014 - League of Legends Trading - 1 Replies
Ich suche einen League of legends Account level 30 (Westeuropa) kann unranked sein zahle bis 10kk Nostale (DE) Server2 gold google Translation (Englisch) I search for a League of Legends account level 30 (Western Europe) may be unranked pay 10kk to Nostale (DE) Server2 gold
Suche dringend 50€ PSC - gebe 50€ PayPal (gebe Trusted Usern first)
07/15/2013 - Trading - 13 Replies
Ist wirklich dringend, einfach melden Nur PSC aus DE + Offline
Suche Yang auf Antharos (Server5) gebe gebe PSC (habe 20€ PSC)
04/10/2012 - Metin2 Trading - 0 Replies
Hallo ich suche Yang auf dem Server Antharos, außerdem suche ich Krieger EQ (bis Level 55). Bitte um schnelle antwort.



All times are GMT +1. The time now is 13:21.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.