added clock implementation

This commit is contained in:
hendrik schutter 2018-04-05 11:08:50 +02:00
parent 2167ac60cc
commit 77c387bfd0
7 changed files with 36 additions and 11 deletions

Binary file not shown.

View File

@ -353,7 +353,7 @@
<Font name="Cantarell Regular" size="26.0" />
</font>
</Label>
<Label fx:id="labelTime" alignment="TOP_RIGHT" contentDisplay="CENTER" layoutX="7.0" layoutY="11.0" prefHeight="15.0" prefWidth="392.0" text="Uhrzeit: 12:15" textAlignment="CENTER">
<Label fx:id="labelTime" alignment="TOP_RIGHT" layoutX="7.0" layoutY="11.0" maxHeight="33.0" maxWidth="392.0" minHeight="33.0" minWidth="392.0" prefHeight="33.0" prefWidth="392.0" text="Uhrzeit: 12:15">
<font>
<Font name="Cantarell Regular" size="26.0" />
</font>

View File

@ -6,11 +6,18 @@ import java.security.GeneralSecurityException;
import java.security.SecureRandom;
import java.util.Optional;
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;
import javafx.animation.Animation;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.geometry.Insets;
import javafx.stage.Stage;
import javafx.util.Duration;
import javafx.util.Pair;
import javafx.scene.Node;
import javafx.scene.Scene;
@ -59,7 +66,14 @@ public class Main extends Application
scene.getStylesheets()
.add(Main.class.getResource("application.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show(); // zeigt die Stage an
primaryStage.show(); // shows the stage
Timeline timeline = new Timeline(
new KeyFrame(Duration.seconds(1), ev -> {
mwc.updateTimeLabel(); //update time
}));
timeline.setCycleCount(Animation.INDEFINITE);
timeline.play();
} catch (Exception e) {
e.printStackTrace();
}

View File

@ -353,7 +353,7 @@
<Font name="Cantarell Regular" size="26.0" />
</font>
</Label>
<Label fx:id="labelTime" alignment="TOP_RIGHT" contentDisplay="CENTER" layoutX="7.0" layoutY="11.0" prefHeight="15.0" prefWidth="392.0" text="Uhrzeit: 12:15" textAlignment="CENTER">
<Label fx:id="labelTime" alignment="TOP_RIGHT" layoutX="7.0" layoutY="11.0" maxHeight="33.0" maxWidth="392.0" minHeight="33.0" minWidth="392.0" prefHeight="33.0" prefWidth="392.0" text="Uhrzeit: 12:15">
<font>
<Font name="Cantarell Regular" size="26.0" />
</font>

View File

@ -29,8 +29,14 @@ import java.io.OutputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.sql.DriverManager;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Optional;
import java.util.Properties;
import java.util.Timer;
import java.util.TimerTask;
import javax.security.auth.callback.Callback;
import javax.swing.plaf.basic.BasicInternalFrameTitlePane.TitlePaneLayout;
import javafx.application.Platform;
@ -281,6 +287,8 @@ public class MainWindowController
private String databaseName;
private boolean lockState = false;
@FXML
TreeItem<tableData> rootCurrentJob = new TreeItem<>(
@ -426,7 +434,8 @@ public class MainWindowController
@FXML
public void gridButton01Action(ActionEvent event)
{
System.out.println("Button!");
System.out.println("Test Button!");
}
@FXML
@ -596,8 +605,6 @@ public class MainWindowController
System.out.println("initUI");
tftNewDBName.setText(getDatabaseName());
initPositionen();
}
private void initPositionen()
@ -686,12 +693,11 @@ public class MainWindowController
this.dbc = dbc;
}
public String getSystemDatum()
public String getSystemTime()
{
java.util.Date now = new java.util.Date();
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(
"dd.MM.yyyy");
String heutigesDatum = sdf.format(now);
DateFormat dateFormat = new SimpleDateFormat("HH:mm");
Date date = new Date();
String heutigesDatum = dateFormat.format(date);
return heutigesDatum;
}
@ -936,5 +942,10 @@ public class MainWindowController
return gridButton01;
}
}
public void updateTimeLabel () {
//System.out.println(getSystemTime());
labelTime.setText("Uhrzeit: " + getSystemTime());
}
}