Create a Clock in Java and Netbeans

VertexDigitalArts · 77K views · 2013 · 14:35

Open on YouTube

Software practice, open source & careersPython, Ruby & scripting languagestutorialdated

Why Stack Overflow recommends it

Stack Overflow users link it as a source for a basic Java digital clock, either as a starting point for time-based apps like alarm clocks or as the tutorial whose code they followed and then hit threading problems with.

Recommended by 1 people across 1 different months, 2015 to 2016.

What it is

A 2013 Java tutorial by VertexDigitalArts that walks through building a digital clock application in NetBeans, using a Swing JFrame and a loop that reads the current time from a Calendar object. It is part of a series on building applications with NetBeans.

What people said

Recommends Blasanka · 2016-07 · Stack Overflow · on “How to compute times for alarm clock app?”

You can use date object.Here is video lesson I found in youtube. create digital clock [this video] while(time == 0){ Calendar calen = new GregorianCalendar(); int hr = calen.get(Calendar.HOUR); int min = calen.get(Calendar.MINUTE); int sec = calen.get(Calendar.SECOND); int AP = calen.get(Calendar.AM_PM); String d_n = ""; if(AP == 1){ d_n = "PM"; }else{ d_n = "AM"; } }

Cites Tomasz Mularczyk · 2015-02 · Stack Overflow · on “new Thread, application still running after Stage-close”

So I followed this tutorial: [this video] and I made exactly the same code in javafx8. public class CountdownController implements Initializable{ @FXML private Label labTime; @Override public void initialize(URL location, ResourceBundle resources) { new Thread(){ public void run(){ while(true){ Calendar calendar = new GregorianCalendar(); int hour = calendar.get(Calendar.HOUR); int minute = calendar.get(Calendar.MINUTE); int second = calendar.get(Calendar.SECOND); String time = hour + ":" + minute + ":" + second; labTime.setText(time); } } }.start(); } After I close the Window, application/thread is still running in the system. My guess its because the infinite loop, but shouldnt the thread be te

Cites Vicente Bermúdez · 2015-04 · Stack Overflow · on “java.lang.IllegalStateException: Not on FX application thread; currentThread = Thread-4”

I'm trying to set the string of a Text object from a Thread but it's giving me this error: Exception in thread "Thread-4" java.lang.IllegalStateException: Not on FX application thread; currentThread = Thread-4 at com.sun.javafx.tk.Toolkit.checkFxUserThread(Unknown Source) at com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(Unknown Source) at javafx.scene.Scene.addToDirtyList(Unknown Source) at javafx.scene.Node.addToSceneDirtyList(Unknown Source) at javafx.scene.Node.impl_markDirty(Unknown Source) at javafx.scene.shape.Shape.impl_markDirty(Unknown Source) at javafx.scene.Node.impl_geomChanged(Unknown Source) at javafx.scene.text.Text.impl_geomChanged(Unknown Source) at javafx.scene