Created TimePicker and tried to add to grid

This commit is contained in:
Marco Kühn 2022-01-13 08:30:56 +01:00
parent eb55d5c650
commit 0d105be15c
3 changed files with 21 additions and 12 deletions

View File

@ -1,24 +1,24 @@
package main; package main;
import com.jfoenix.controls.JFXTimePicker;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage; import javafx.stage.Stage;
import res.DataController; import res.DataController;
import res.Event; import res.Event;
public class CreateEventController { public class CreateEventController {
@FXML
public GridPane grid;
@FXML @FXML
public DatePicker datePickerDate; public DatePicker datePickerDate;
@FXML @FXML
public TextField textName; public TextField textName;
@FXML @FXML
public TextField textStart;
@FXML
public TextField textEnd;
@FXML
public ComboBox<String> ComboBoxTyp; public ComboBox<String> ComboBoxTyp;
@FXML @FXML
public ComboBox<String> ComboBoxPriotity; public ComboBox<String> ComboBoxPriotity;
@ -28,6 +28,10 @@ public class CreateEventController {
public CheckBox checkBoxIsPrivate; public CheckBox checkBoxIsPrivate;
@FXML @FXML
public Label labelError; public Label labelError;
@FXML
public JFXTimePicker timeStart;
@FXML
public JFXTimePicker timeEnd;
public CreateEventController() { public CreateEventController() {
@ -35,6 +39,15 @@ public class CreateEventController {
@FXML @FXML
public void initialize() { public void initialize() {
JFXTimePicker timePickerStart = new JFXTimePicker();
timeStart = timePickerStart;
timePickerStart.set24HourView(true);
grid.add(timePickerStart, 1 , 3);
JFXTimePicker timePickerEnd = new JFXTimePicker();
timeEnd = timePickerEnd;
timePickerEnd.set24HourView(true);
grid.add(timePickerEnd, 1 , 4);
} }
@ -50,8 +63,8 @@ public class CreateEventController {
ComboBoxPriotity.getSelectionModel().getSelectedIndex(), ComboBoxPriotity.getSelectionModel().getSelectedIndex(),
checkBoxIsFullDay.isSelected(), checkBoxIsFullDay.isSelected(),
checkBoxIsPrivate.isSelected(), checkBoxIsPrivate.isSelected(),
textStart.getText(), timeStart.toString(),
textEnd.getText(), timeEnd.toString(),
datePickerDate.getValue().atStartOfDay(), datePickerDate.getValue().atStartOfDay(),
(int) DataController.USER_ID (int) DataController.USER_ID
); );

View File

@ -1,7 +1,5 @@
package main; package main;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.geometry.Pos; import javafx.geometry.Pos;

View File

@ -2,10 +2,10 @@
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<?import javafx.collections.FXCollections?> <?import javafx.collections.FXCollections?>
<?import java.lang.String?> <?import java.lang.String?>
<GridPane xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml/1"
<GridPane fx:id="grid" xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="main.CreateEventController"> fx:controller="main.CreateEventController">
<columnConstraints> <columnConstraints>
@ -39,8 +39,6 @@
<DatePicker fx:id="datePickerDate" GridPane.columnIndex="1" GridPane.rowIndex="1" maxWidth="400" minWidth="400"/> <DatePicker fx:id="datePickerDate" GridPane.columnIndex="1" GridPane.rowIndex="1" maxWidth="400" minWidth="400"/>
<TextField fx:id="textName" GridPane.columnIndex="1" GridPane.rowIndex="2" maxWidth="400" minWidth="400"/> <TextField fx:id="textName" GridPane.columnIndex="1" GridPane.rowIndex="2" maxWidth="400" minWidth="400"/>
<TextField fx:id="textStart" GridPane.columnIndex="1" GridPane.rowIndex="3" maxWidth="400" minWidth="400"/>
<TextField fx:id="textEnd" GridPane.columnIndex="1" GridPane.rowIndex="4" maxWidth="400" minWidth="400"/>
<ComboBox fx:id="ComboBoxTyp" GridPane.columnIndex="1" GridPane.rowIndex="5" maxWidth="400" minWidth="400"/> <ComboBox fx:id="ComboBoxTyp" GridPane.columnIndex="1" GridPane.rowIndex="5" maxWidth="400" minWidth="400"/>
<ComboBox fx:id="ComboBoxPriotity" GridPane.columnIndex="1" GridPane.rowIndex="6" maxWidth="200" minWidth="200"> <ComboBox fx:id="ComboBoxPriotity" GridPane.columnIndex="1" GridPane.rowIndex="6" maxWidth="200" minWidth="200">
<items> <items>