Airport System
Airport System
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.*;
import javafx.stage.Stage;
@Override
public void start(Stage primaryStage) {
VBox layout = new VBox(15);
layout.setPadding(new Insets(20));
scene.getStylesheets().add(getClass().getResource("tecketlistStyle.css").toE
xternalForm());
primaryStage.setScene(scene);
primaryStage.setTitle("Reservations");
primaryStage.show();
}
table.getColumns().addAll(
createCol("Passenger ID", "passengerId"),
createCol("Passport No", "passportNumber"),
createCol("Full Name", "fullName"),
createCol("Gender", "gender"),
createCol("Nationality", "nationality"),
createCol("Ticket Code", "ticketCode"),
createCol("Ticket Price", "ticketPrice")
);
table.setItems(getSampleReservations());
return table;
}
loginButton.getStyleClass().add("login-button");
loginButton.setOnAction(event -> {
String username = usernameField.getText();
String password = passwordField.getText();
if (username.isEmpty() || password.isEmpty()) {
Alert successLoginAlert = new Alert(Alert.AlertType.INFORMATION);
successLoginAlert.setTitle("Error");
// successLoginAlert.setHeaderText("User ");
successLoginAlert.setContentText("Username Or Password Can not be
Empty!!");
successLoginAlert.showAndWait();
return;
}
if (AuthenticationService.loginUser(username,password)) {
Alert successLoginAlert = new Alert(Alert.AlertType.INFORMATION);
successLoginAlert.setTitle("Success");
successLoginAlert.setHeaderText("Success Opreation");
successLoginAlert.setContentText("passenger added seccussfully");
successLoginAlert.showAndWait();
}
else {
Alert successLoginAlert = new Alert(Alert.AlertType.INFORMATION);
successLoginAlert.setTitle("Error");
// successLoginAlert.setHeaderText("Success Opreation");
successLoginAlert.setContentText("Data that entered is incorrect");
successLoginAlert.showAndWait();
}
});
});
loginBox.setAlignment(Pos.CENTER);
//loginBox.setMaxHeight(300);
loginBox.setPadding(new Insets(20));
loginBox.setMaxWidth(300);
loginBox.getStyleClass().add("login-box");
scene.getStylesheets().add(getClass().getResource("LoginStyle.css").toExternalForm());
mediaView.fitWidthProperty().bind(scene.widthProperty());
mediaView.fitHeightProperty().bind(scene.heightProperty());
mediaView.setPreserveRatio(false);
primaryStage.setTitle("Mohammed App");
primaryStage.setScene(scene);
primaryStage.show();
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.NodeOrientation;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.scene.text.Text;
import javafx.stage.Stage;
formBox.getChildren().addAll(usernameBox,genderBox,userEmailBox,passwordBox,confirmPassword
Box,userCodeBox,buttonBox);
borderPane.setTop(header);
borderPane.setCenter(formBox);
borderPane.setBottom(footer);
Scene scene = new Scene(borderPane,1800,950);
scene.getStylesheets().add(getClass().getResource("SinginStyle.css").toExternalForm());
scene.setNodeOrientation(NodeOrientation.LEFT_TO_RIGHT);
primaryStage.setTitle("Sign Up");
primaryStage.setScene(scene);
primaryStage.show();
}
Class 3 :
package AirportSystem;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.geometry.VPos;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.paint.CycleMethod;
import javafx.scene.paint.RadialGradient;
import javafx.scene.paint.Stop;
import javafx.scene.shape.Line;
import javafx.scene.shape.Polygon;
import javafx.scene.text.Font;
import java.lang.String;
import javafx.scene.text.FontWeight;
import javafx.scene.text.TextAlignment;
import javafx.stage.Stage;
import javafx.util.Duration;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.YearMonth;
@Override
public void start(Stage primatyStage) {
HBox.setHgrow(clockBox,Priority.ALWAYS);
HBox.setHgrow(calenderBox,Priority.ALWAYS);
bottomPane.getChildren().addAll(clockBox,dateBox,calenderBox);
}
private StackPane createRhombusRow() {
StackPane layer = new StackPane();
String[] iconPaths =
{"/AirportSystem/Pictures/m007.PNG","/AirportSystem/Pictures/s001.PNG","/AirportSystem/
Pictures/s004.PNG",
"/AirportSystem/Pictures/n003.PNG","/AirportSystem/Pictures/m005.PNG"};
String[] labels = {"Enter a trip","Flight list","Book a ticket","Listowns","User\
nmanagement"};
rhombus.getStyleClass().add("rhombus-base");
label.getStyleClass().add("rhombus-label");
icon.setFitHeight(75);
icon.setFitWidth(120);
itemcontainer.getChildren().addAll(rhombus,label,iconPane);
itemcontainer.setOnMouseEntered(event ->
{
itemcontainer.setScaleX(1.17);
itemcontainer.setScaleY(1.17);
rhombus.getStyleClass().remove("rhombus-base");
rhombus.getStyleClass().add("rhombus-hover");
});
itemcontainer.setOnMouseExited(event ->
{
itemcontainer.setScaleX(1.0);
itemcontainer.setScaleY(1.0);
//iconPane.setTranslateY(-44);
rhombus.getStyleClass().remove("rhombus-hover");
rhombus.getStyleClass().add("rhombus-base");
});
rhombusRow.getChildren().add(itemcontainer);
layer.getChildren().addAll(titleLabel,rhombusRow);
return layer;
}
private GridPane createCalender() {
GridPane grid = new GridPane();
grid.setHgap(0);
grid.setVgap(0);
grid.setPadding(new Insets(0));
grid.setAlignment(Pos.CENTER);
grid.setStyle("-fx-max-width: 490px;");
grid.getStyleClass().add("calendar-container");
timeline.setCycleCount(Timeline.INDEFINITE);
timeline.play();
//clockBox.getStyleClass().add("clock-box");
return clockBox;
}
private void drawClock(GraphicsContext gc) {
gc.clearRect(0,0,300,300);
gc.fillOval(CLOCK_CENTER_X-CLOCK_RADIUS,CLOCK_CENTER_Y-
CLOCK_RADIUS,CLOCK_RADIUS*2,CLOCK_RADIUS*2);
gc.setStroke(Color.web("#dddddd"));
gc.setLineWidth(6);
gc.strokeOval(CLOCK_CENTER_X - CLOCK_RADIUS+3, CLOCK_CENTER_Y - CLOCK_RADIUS+3,
(CLOCK_RADIUS-3)*2, (CLOCK_RADIUS-3)*2);
gc.setFill(Color.web("#333333"));
gc.setFont(Font.font("Segoe UI", FontWeight.BOLD,18));
gc.setTextAlign(TextAlignment.CENTER);
gc.setTextBaseline(VPos.CENTER);
gc.setStroke(Color.web("#333333"));
gc.setLineWidth(i%3 == 0 ? 4 : 2);
gc.strokeLine(x1, y1, x2, y2);
}
gc.setFill(Color.GRAY);
gc.setFont(Font.font("Segoe UI",FontWeight.BOLD,18));
for (int i =1; i<=12;i++) {
double angle = Math.toRadians(i*30-90);
double distanceFromCenter = CLOCK_RADIUS-35;
double x = CLOCK_CENTER_X+distanceFromCenter*Math.cos(angle);
double y = CLOCK_CENTER_Y+distanceFromCenter*Math.sin(angle);
gc.fillText(String.valueOf(i),x-5,y+5);
}
}
private void drawHand(GraphicsContext gc,double angleDeg,double length,double width) {
double rad = Math.toRadians( angleDeg - 90);
double x2 = CLOCK_CENTER_X + length*Math.cos(rad);
double y2 = CLOCK_CENTER_Y + length*Math.sin(rad);
gc.setStroke(Color.web("333333"));
gc.setLineWidth(width);
gc.strokeLine(CLOCK_CENTER_X,CLOCK_CENTER_Y,x2,y2);
}
private HBox createDateBox() {
HBox dateBox =new HBox(5);
dateBox.setAlignment(Pos.CENTER);
dateBox.getStyleClass().add("date-box");
}));
timeline.setCycleCount(Timeline.INDEFINITE);
timeline.play();
dateBox.getChildren().addAll(dateLabel,dayLabel);
return dateBox;
}
public static void main(String[] args) {
launch(args);
} }
Class 4 :
package AirportSystem;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.stage.Stage;
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("✈️ Flight Registration Form");
/////////////////////////////////////
VBox planeInfoStair = new VBox(15);
planeInfoStair.setPadding(new Insets(10));
/////////////////////////////////////////////////
//////////
VBox passengerInfoStear = new VBox(15);
passengerInfoStear.setPadding(new Insets(10));
String dataSummary =
"Flight #: " + flightNumber.getText() + "\n" +
"Date: " + flightDate.getValue() + "\n" +
"Time: " + flightTime.getText() + "\n" +
"Plane #: " + planeNumber.getText() + "\n" +
"Plane Name: " + planeName.getText() + "\n" +
"Captain: " + captainName.getText() + "\n" +
"From: " + departureBox.getValue() + "\n" +
"To: " + destinationBox.getValue() + "\n" +
"Seats: " + seats + "\n" +
"Passengers: " + passengers;
confirm.showAndWait().ifPresent(response -> {
if (response == ButtonType.OK) {
Alert success = new Alert(Alert.AlertType.INFORMATION);
success.setTitle("Success");
success.setHeaderText(null);
success.setContentText("Flight saved successfully!");
success.showAndWait();
}
});
root.setPadding(new Insets(40));
root.setAlignment(Pos.TOP_LEFT);
// إنشاءGridPane موحد
private GridPane createGridPane() {
GridPane grid = new GridPane();
grid.setHgap(25);
grid.setVgap(20);
grid.setPadding(new Insets(20));
grid.setAlignment(Pos.TOP_LEFT);
ColumnConstraints col1 = new ColumnConstraints();
col1.setPercentWidth(25);
ColumnConstraints col2 = new ColumnConstraints();
col2.setPercentWidth(75);
grid.getColumnConstraints().addAll(col1, col2);
return grid;
}
comboBox.setItems(filtered);
comboBox.getEditor().textProperty().addListener((obs, oldVal, newVal) -> {
final String filter = newVal.toLowerCase();
filtered.setPredicate(item -> item.toLowerCase().contains(filter));
});
comboBox.setOnAction(e -> {
String selected= comboBox.getSelectionModel().getSelectedItem();
if (selected != null)
comboBox.getEditor().setText(selected);
});
return comboBox;
}
}
Class 5:
package AirportSystem;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.*;
import javafx.stage.Stage;
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("✈️ Flight Management System");
flights = createSampleData();
table.setItems(flights);
scene.getStylesheets().add(getClass().getResource("flaylistStyle.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();
}
table.getColumns().addAll(
flightNumberCol, dateCol, timeCol,
planeNumberCol, planeNameCol, captainCol,
departureCol, destinationCol,
seatsCol, passengersCol, actionsCol
);
}
private TableColumn<Flight, String> createColumn(String title, String property, double
width) {
TableColumn<Flight, String> col = new TableColumn<>(title);
col.setCellValueFactory(new PropertyValueFactory<>(property));
col.setPrefWidth(width);
col.setMinWidth(width * 0.8); // حد أدنى للعرض
col.setStyle("-fx-alignment: CENTER; -fx-border-color: #e0e0e0; -fx-border-width: 1
1 1 1;");
return col;
}
{
btn.getStyleClass().add("view-btn");
btn.setMaxWidth(Double.MAX_VALUE);
btn.setOnAction(e -> {
Flight flight = getTableView().getItems().get(getIndex());
if (flight != null) openReservationsView(flight);
});
}
@Override
protected void updateItem(Void item, boolean empty) {
super.updateItem(item, empty);
setGraphic(empty ? null : btn);
}
});
return col;
}
return flights;
}
package AirportSystem;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
import java.text.DateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
gridPane.setId("graid-pane-container");
Label newTicket = new Label("New Ticket");
newTicket.setId("new-ticket");
genderMenu.setPromptText("Select Gender");
});
passengerNationalityMenu.setItems(FXCollections.observableArrayList(filteredNationalityList
));
passengerNationalityMenu.show();
});
Label passportDateISS = new Label("Date of Issue :");
TextField passportDateISSField = new TextField();
passportDateISSField.setPromptText("Select Date");
DatePicker dateofISSPassport = new DatePicker();
dateofISSPassport.setVisible(false);
passportDateISSField.setOnMouseClicked(event -> dateofISSPassport.show());
dateofISSPassport.setOnAction(event -> {
LocalDate selectionDate = dateofISSPassport.getValue();
if (selectionDate != null) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String formattedDate = selectionDate.format(formatter);
passportDateISSField.setText(formattedDate);
}
});
dateofEXPassport.setOnAction(event -> {
LocalDate selectionDate = dateofEXPassport.getValue();
if (selectionDate != null) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String formattedDate = selectionDate.format(formatter);
passportDateEXField.setText(formattedDate);
}
});
travelFromField.getEditor().getText(),travelToField.getEditor().getText(),ticketCodeField.g
etText(),
Double.parseDouble(ticketPriceField.getText()));
DatabaseHandler.addPassenger(newPassenger);
Alert successAlert = new Alert(Alert.AlertType.INFORMATION);
successAlert.setTitle("Success");
successAlert.setHeaderText("Success Opreation");
successAlert.setContentText("passenger added seccussfully");
successAlert.showAndWait();
System.out.println("");
} catch (NumberFormatException e) {
Alert errorAlert = new Alert(Alert.AlertType.ERROR);
errorAlert.setTitle("Invalid Ticket Price");
errorAlert.setHeaderText(null);
errorAlert.setContentText("Please enter a valid numeric ticket price.");
errorAlert.showAndWait();
}
});
gridPane.add(newTicket,2,0,2,1);
gridPane.add(passportData,0,1,4,1);
gridPane.add(passengerID,0,2);
gridPane.add(passengerIDField,0,3);
gridPane.add(passportNo,1,2);
gridPane.add(passportNoField,1,3);
gridPane.add(passengerName,2,2);
gridPane.add(passengerNameField,2,3);
gridPane.add(passengerFatherName,3,2);
gridPane.add(passengerFatherNameField,3,3);
gridPane.add(passengerGrandName,4,2);
gridPane.add(passengerGrandNameField,4,3);
gridPane.add(surname,0,4);
gridPane.add(surnameField ,0,5);
gridPane.add(passengerGender,1,4);
gridPane.add(genderMenu,1,5);
gridPane.add(passengerBirth,2,4);
gridPane.add(passengerBirthField,2,5);
gridPane.add(passengerAge,3,4);
gridPane.add(passengerAgeField,3,5);
gridPane.add(passengerCountry,4,4);
gridPane.add(countries,4,5);
gridPane.add(passengerNationality,0,6);
gridPane.add(passengerNationalityMenu,0,7);
gridPane.add(passportDateISS,1,6);
gridPane.add(passportDateISSField,1,7);
gridPane.add(dateofISSPassport,1,7);
gridPane.add(passportDateEX,2,6);
gridPane.add(passportDateEXField,2,7);
gridPane.add(dateofEXPassport,2,7);
gridPane.add(travelData,0,8,3,1);
gridPane.add(travelCode,0,9);
gridPane.add(trvelCodeField,0,10);
gridPane.add(travelFrom,1,9);
gridPane.add(travelFromField,1,10);
gridPane.add(travelTo,2,9);
gridPane.add(travelToField,2,10);
gridPane.add(ticketData,0,11,2,1);
gridPane.add(ticketCode,0,12);
gridPane.add(ticketCodeField,0,13);
gridPane.add(ticketPrice,1,12);
gridPane.add(ticketPriceField,1,13);
gridPane.add(cancelButton,1,15);
gridPane.add(submitButton,3,15);
gridPane.setAlignment(Pos.CENTER);
gridPane.setVgap(10);
gridPane.setHgap(10);
scene.getStylesheets().add(getClass().getResource("ticketStyle.css").toExternalForm());
primaryStage.setTitle("TICKET");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Class 6:
package AirportSystem;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.*;
import javafx.stage.Stage;
@Override
public void start(Stage primaryStage) {
try {
// التحقق من أنselectedFlight غيرnull
if (selectedFlight == null) {
throw new IllegalStateException("Flight data is not available");
}
mainLayout.setStyle("-fx-background-color: #f9f9f9;");
scene.getStylesheets().add(getClass().getResource("tecketlistStyle.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();
} catch (Exception e) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Error");
alert.setHeaderText("Failed to open window");
alert.setContentText(e.getMessage());
alert.showAndWait();
}
}
private VBox createFlightInfoSection() {
Label titleLabel = new Label("Flight Information");
titleLabel.setStyle("-fx-font-size: 18px; -fx-font-weight: bold;");
// إنشاء زر العودة
Button backButton = new Button("← Back");
backButton.setStyle("-fx-font-size: 14px; -fx-background-color: #607D8B; -fx-text-
fill: white;");
backButton.setOnAction(e -> ((Stage) backButton.getScene().getWindow()).close());
return flightInfoBox;
}
return box;
}
private void setupReservationsTable(TableView<Reservation> table) {
// Passenger Information Columns
TableColumn<Reservation, String> passengerIdCol = new TableColumn<>("Passenger
ID");
passengerIdCol.setCellValueFactory(new PropertyValueFactory<>("passengerId"));
table.getColumns().addAll(
passengerIdCol, passportNoCol, fullNameCol,
genderCol, birthYearCol, ageCol, countryCol, nationalityCol,
passportIssueCol, passportExpiryCol, travelCodeCol, travelFromCol,
travelToCol,
ticketCodeCol, ticketPriceCol
);
table.setItems(getSampleReservations());
}
package AirportSystem;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javafx.util.converter.IntegerStringConverter;
@Override
public void start(Stage primaryStage) {
table = new TableView<>();
table.setEditable(true);
// تعيين األعمدة
TableColumn<User, Integer> idCol = new TableColumn<>("ID");
idCol.setCellValueFactory(new PropertyValueFactory<>("id"));
idCol.setCellFactory(TextFieldTableCell.forTableColumn(new
IntegerStringConverter()));
idCol.setOnEditCommit(e -> e.getRowValue().setId(e.getNewValue()));
// بيانات تجريبية
data = FXCollections.observableArrayList(
new User(1, "ahmed", "admin", "Male", "admin", "admin",
"[email protected]"));
table.setItems(data);
// لمربع األزرار
buttonBox.getStyleClass().add("button-box");
scene.getStylesheets().add(getClass().getResource("userManagementStyle.css").toExternalForm
());
primaryStage.setScene(scene);
primaryStage.setTitle("User Management");
primaryStage.show();
}
confirmAddBtn.setId("confirmAddBtn");
inputFieldsBox.getStyleClass().add("popup-window");
idLabel.getStyleClass().add("popup-label");
usernameLabel.getStyleClass().add("popup-label");
// ... وهكذا لباقي الـLabels
idField.getStyleClass().add("popup-textfield");
usernameField.getStyleClass().add("popup-textfield");
confirmAddBtn.setOnAction(evt -> {
try {
User user = new User(
Integer.parseInt(idField.getText()),
usernameField.getText(),
userCodeField.getText(),
genderField.getText(),
passwordField.getText(),
roleField.getText(),
emailField.getText()
);
if (!user.getUsername().isEmpty()) {
data.add(user);
popupStage.close();
}
} catch (NumberFormatException ex) {
System.out.println("Invalid ID.");
}
});
inputFieldsBox.getChildren().addAll(
idLabel, idField,
usernameLabel, usernameField,
userCodeLabel, userCodeField,
genderLabel, genderField,
passwordLabel, passwordField,
roleLabel, roleField,
emailLabel, emailField,
confirmAddBtn
);
inputFieldsBox.setAlignment(Pos.CENTER);
public User(int id, String username, String userCode, String gender, String
password, String role, String email) {
this.id = id;
this.username = username;
this.userCode = userCode;
this.gender = gender;
this.password = password;
this.role = role;
this.email = email;
}
package AirportSystem;
this.travelTo = travelTo;
this.ticketCode = ticketCode;
this.ticketPrice = ticketPrice;
}
}
Class 9:
package AirportSystem;
import java.util.HashMap;
import java.util.Map;
package AirportSystem;
import javafx.application.Application;
import javafx.stage.Stage;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;