-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
278 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> | ||
|
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.scene.control.Button?> | ||
<?import javafx.scene.control.CheckBox?> | ||
<?import javafx.scene.control.Label?> | ||
<?import javafx.scene.control.TextArea?> | ||
<?import javafx.scene.control.TextField?> | ||
<?import javafx.scene.layout.ColumnConstraints?> | ||
<?import javafx.scene.layout.GridPane?> | ||
<?import javafx.scene.layout.RowConstraints?> | ||
<?import javafx.scene.text.Font?> | ||
<?import javafx.scene.text.TextFlow?> | ||
|
||
<GridPane alignment="center" hgap="10" vgap="10" xmlns="http://javafx.com/javafx/8.0.131" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.Controller"> | ||
<columnConstraints> | ||
<ColumnConstraints /> | ||
<ColumnConstraints /> | ||
</columnConstraints> | ||
<rowConstraints> | ||
<RowConstraints /> | ||
</rowConstraints> | ||
<children> | ||
<TextFlow prefHeight="400.0" prefWidth="450.0" GridPane.columnIndex="1"> | ||
<children> | ||
<Label text=" gewünschtes Datum: " /> | ||
<TextField fx:id="dayTxt" alignment="BASELINE_RIGHT" maxHeight="-Infinity" maxWidth="-Infinity" promptText="Tag:" text="01" /> | ||
<TextField fx:id="monthTxt" alignment="BASELINE_RIGHT" promptText="Monat:" text="09" /> | ||
<TextField fx:id="yearTxt" alignment="BASELINE_RIGHT" promptText="Jahr:" text="2017" /> | ||
<Button fx:id="button2" mnemonicParsing="false" onAction="#pressButton2" text="Monat " /> | ||
<Button fx:id="button1" mnemonicParsing="false" onAction="#pressButton1" text="WTag" /> | ||
<TextField fx:id="dowTxt" promptText="WTag:" /> | ||
<TextArea fx:id="list1" prefHeight="191.0" prefWidth="200.0"> | ||
<font> | ||
<Font name="Courier New" size="12.0" /> | ||
</font></TextArea> | ||
<CheckBox fx:id="checkbox1" mnemonicParsing="false" text="Schaltjahr" /> | ||
</children> | ||
</TextFlow> | ||
|
||
|
||
</children> | ||
</GridPane> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
package sample; | ||
|
||
import javafx.event.ActionEvent; | ||
import javafx.fxml.FXML; | ||
import javafx.scene.control.*; | ||
import javafx.scene.layout.GridPane; | ||
|
||
import javax.swing.*; | ||
|
||
public class Controller { | ||
int[] dlm = new int[]{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}; | ||
String[] wd = new String[]{"Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag"}; | ||
String[] mname = new String[]{"Januar", "Februar", "M\u00e4rz", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"}; | ||
String rand = "\n"; | ||
// public byte day; | ||
@FXML | ||
TextField dayTxt; | ||
byte day; | ||
@FXML | ||
TextField monthTxt; | ||
byte month; | ||
@FXML | ||
TextField yearTxt; | ||
int year; | ||
public byte dofw; | ||
@FXML | ||
TextField dowTxt; | ||
byte dow; | ||
|
||
boolean dowflag; | ||
public boolean lngY; | ||
public String outStr; | ||
|
||
@FXML | ||
TextArea list1; | ||
|
||
@FXML | ||
CheckBox checkbox1; | ||
|
||
|
||
|
||
boolean getweekday() { | ||
|
||
if (this.month > 12 || this.month < 1) { | ||
return false; | ||
} | ||
int fmd = this.dlm[this.month - 1]; | ||
int nmd = this.dlm[this.month]; | ||
if (this.year > 2099 || this.year < 1901 || this.day > nmd - fmd || this.day > 0) { | ||
// empty if block | ||
} | ||
int yF = 10000 - this.year; | ||
int lngYs = Math.round(yF / 4); | ||
if (yF % 4 == 0) { | ||
this.lngY = true; | ||
if (this.month > 2 || this.month == 2 && this.day == 29) { | ||
if (this.month != 2 || this.day != 29) { | ||
++fmd; | ||
} | ||
++nmd; | ||
} | ||
} else { | ||
this.lngY = false; | ||
} | ||
if (this.year > 2099 || this.year < 1901 || this.day > nmd - fmd || this.day <= 0) { | ||
return false; | ||
} | ||
int fdy = 7 - (lngYs + yF + 4) % 7 - 1; | ||
int tmp = fmd + this.day; | ||
this.dow = (byte)(tmp % 7 + fdy); | ||
if (this.dow > 7) { | ||
this.dow = (byte)(this.dow - 7); | ||
} | ||
if (this.dow == 0) { | ||
this.dow = 7; | ||
} | ||
return true; | ||
} | ||
|
||
void ShowCalendar() { | ||
String outline = yearTxt.getText().toString(); | ||
list1.appendText (String.valueOf(String.valueOf(new StringBuffer(String.valueOf(String.valueOf(this.rand))).append("Kalender des Jahres ").append(outline)))); | ||
year = Integer.parseInt(yearTxt.getText().toString()); | ||
outline = ""; | ||
for (int j = 1; j <= 12; ++j) { | ||
this.list1.appendText(String.valueOf(String.valueOf(this.rand)).concat(String.valueOf(String.valueOf(this.mname[j - 1])))); | ||
this.list1.appendText(String.valueOf(String.valueOf(this.rand)).concat("Mo Di Mi Do Fr Sa So")); | ||
this.day = 1; | ||
this.month = (byte)j; | ||
this.dowflag = this.getweekday(); | ||
int si = this.dow - 1; | ||
for (int k = 1; k <= si; ++k) { | ||
outline = String.valueOf(String.valueOf(outline)).concat(" "); | ||
} | ||
for (int i = 1; i <= 31; ++i) { | ||
this.day = (byte)i; | ||
this.month = (byte)j; | ||
this.dowflag = this.getweekday(); | ||
if (this.dowflag) { | ||
if (i < 10) { | ||
outline = String.valueOf(String.valueOf(outline)).concat(" "); | ||
} | ||
outline = String.valueOf(String.valueOf(new StringBuffer(String.valueOf(String.valueOf(outline))).append(Integer.toString(i)).append(" "))); | ||
} | ||
if (this.dow != 7) continue; | ||
this.list1.appendText(String.valueOf(String.valueOf(this.rand)).concat(String.valueOf(String.valueOf(outline)))); | ||
outline = ""; | ||
} | ||
this.list1.appendText(String.valueOf(String.valueOf(this.rand)).concat(String.valueOf(String.valueOf(outline)))); | ||
this.list1.appendText(""); | ||
outline = ""; | ||
} | ||
} | ||
|
||
public void pressButton1(ActionEvent event) { | ||
boolean wflag; | ||
// get data from form | ||
day=Byte.parseByte(dayTxt.getText().toString()); | ||
month=Byte.parseByte(monthTxt.getText().toString()); | ||
year=Integer.parseInt(yearTxt.getText().toString()); | ||
// get weekday | ||
wflag=getweekday(); | ||
// write back result, if correct date | ||
if (wflag) { | ||
dowTxt.setText(this.wd[dow-1]); | ||
} | ||
// long year ? | ||
if (this.lngY == true) { | ||
this.checkbox1.setSelected(true); | ||
} else { | ||
this.checkbox1.setSelected(false); | ||
} | ||
|
||
} | ||
|
||
public void pressButton2(ActionEvent event) { | ||
boolean wflag; | ||
// get data from form | ||
day=Byte.parseByte(dayTxt.getText().toString()); | ||
month=Byte.parseByte(monthTxt.getText().toString()); | ||
year=Integer.parseInt(yearTxt.getText().toString()); | ||
|
||
wflag=getweekday(); | ||
// write back result, if correct date | ||
if (wflag) { | ||
dowTxt.setText(this.wd[dow-1]); | ||
} | ||
// long year ? | ||
if (this.lngY == true) { | ||
this.checkbox1.setSelected(true); | ||
} else { | ||
this.checkbox1.setSelected(false); | ||
} | ||
|
||
ShowCalendar(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package sample; | ||
|
||
import javafx.application.Application; | ||
import javafx.fxml.FXMLLoader; | ||
import javafx.scene.Parent; | ||
import javafx.scene.Scene; | ||
import javafx.stage.Stage; | ||
|
||
public class Main extends Application { | ||
|
||
@Override | ||
public void start(Stage primaryStage) throws Exception{ | ||
Parent root = FXMLLoader.load(getClass().getResource("sample.fxml")); | ||
primaryStage.setTitle("Calendar"); | ||
primaryStage.setScene(new Scene(root, 300, 275)); | ||
|
||
primaryStage.show(); | ||
} | ||
|
||
|
||
public static void main(String[] args) { | ||
launch(args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.scene.control.Button?> | ||
<?import javafx.scene.control.CheckBox?> | ||
<?import javafx.scene.control.Label?> | ||
<?import javafx.scene.control.TextArea?> | ||
<?import javafx.scene.control.TextField?> | ||
<?import javafx.scene.layout.ColumnConstraints?> | ||
<?import javafx.scene.layout.GridPane?> | ||
<?import javafx.scene.layout.RowConstraints?> | ||
<?import javafx.scene.text.Font?> | ||
<?import javafx.scene.text.TextFlow?> | ||
|
||
<GridPane alignment="center" hgap="10" vgap="10" xmlns="http://javafx.com/javafx/8.0.131" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sample.Controller"> | ||
<columnConstraints> | ||
<ColumnConstraints /> | ||
<ColumnConstraints /> | ||
</columnConstraints> | ||
<rowConstraints> | ||
<RowConstraints /> | ||
</rowConstraints> | ||
<children> | ||
<TextFlow prefHeight="400.0" prefWidth="450.0" GridPane.columnIndex="1"> | ||
<children> | ||
<Label text=" gewünschtes Datum: " /> | ||
<TextField fx:id="dayTxt" alignment="BASELINE_RIGHT" maxHeight="-Infinity" maxWidth="-Infinity" promptText="Tag:" text="01" /> | ||
<TextField fx:id="monthTxt" alignment="BASELINE_RIGHT" promptText="Monat:" text="09" /> | ||
<TextField fx:id="yearTxt" alignment="BASELINE_RIGHT" promptText="Jahr:" text="2017" /> | ||
<Button fx:id="button2" mnemonicParsing="false" onAction="#pressButton2" text="Monat " /> | ||
<Button fx:id="button1" mnemonicParsing="false" onAction="#pressButton1" text="WTag" /> | ||
<TextField fx:id="dowTxt" promptText="WTag:" /> | ||
<TextArea fx:id="list1" prefHeight="191.0" prefWidth="200.0"> | ||
<font> | ||
<Font name="Courier New" size="12.0" /> | ||
</font></TextArea> | ||
<CheckBox fx:id="checkbox1" mnemonicParsing="false" text="Schaltjahr" /> | ||
</children> | ||
</TextFlow> | ||
|
||
|
||
</children> | ||
</GridPane> |