-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainApplication.java
More file actions
2495 lines (2139 loc) · 103 KB
/
MainApplication.java
File metadata and controls
2495 lines (2139 loc) · 103 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableRowSorter;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.lang.SecurityException;
import java.util.Formatter;
import java.util.FormatterClosedException;
import java.util.NoSuchElementException;
import java.util.Scanner;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableRowSorter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Vector;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.time.DateTimeException;
import java.time.LocalDate;
import java.time.format.DateTimeParseException;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern;
import java.awt.event.ActionEvent;
import java.time.LocalDate;
import java.util.Enumeration;
import java.util.Random;
import java.util.Vector;
public class MainApplication {
public static void main(String[] args) {
// LOGO
PlannerApp plannerApp = new PlannerApp();
plannerApp.setVisible(true);
// LOGIN
UserInterface userInterface = new UserInterface();
userInterface.setVisible(true);
// HOMEPAGE
SwingUtilities.invokeLater(() -> {
Homepage hp = new Homepage();
hp.setVisible(true);
});
}
class userinterface extends JFrame {
private static final String DATABASE_URL = "jdbc:mysql://localhost:3306/MTG";
private static final String DATABASE_USER = "root";
private static final String DATABASE_PASSWORD = "System";
public userinterface() {
setTitle("My Tour Guide" )
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(350, 300);
setLocationRelativeTo(null);
setLayout(new BorderLayout());
JTabbedPane tabbedPane = new JTabbedPane();
JPanel loginPanel = new JPanel();
placeComponentsLogin(loginPanel);
tabbedPane.addTab("Login", loginPanel);
JPanel signupPanel = new JPanel();
placeComponentsSignup(signupPanel);
tabbedPane.addTab("Sign Up", signupPanel);
add(tabbedPane, BorderLayout.CENTER);
}
private void placeComponentsLogin(JPanel panel) {
panel.setLayout(new GridLayout(3, 2));
JLabel userLabel = new JLabel("Username:");
JTextField userText = new JTextField();
JLabel passwordLabel = new JLabel("Password:");
JPasswordField passwordText = new JPasswordField();
JButton loginButton = new JButton("Login");
loginButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String username = userText.getText();
String password = new String(passwordText.getPassword());
}
});
panel.add(userLabel);
panel.add(userText);
panel.add(passwordLabel);
panel.add(passwordText);
panel.add(loginButton);
}
private void placeComponentsSignup(JPanel panel) {
panel.setLayout(new GridLayout(5, 2));
JLabel nameLabel = new JLabel("Full Name:");
JTextField nameText = new JTextField();
JLabel emailLabel = new JLabel("Email:");
JTextField emailText = new JTextField();
JLabel passwordLabel = new JLabel("Password:");
JPasswordField passwordText = new JPasswordField();
JLabel phoneLabel = new JLabel("Phone:");
JTextField phoneText = new JTextField();
JButton createAccountButton = new JButton("Create Account");
createAccountButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String name = nameText.getText();
String email = emailText.getText();
String password = new String(passwordText.getPassword());
String phone = phoneText.getText();
try {
insertUserToDatabase(name, email, password, phone);
} catch (SQLException ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(userinterface.this, "Error creating user account.");
}
}
});
panel.add(nameLabel);
panel.add(nameText);
panel.add(emailLabel);
panel.add(emailText);
panel.add(passwordLabel);
panel.add(passwordText);
panel.add(phoneLabel);
panel.add(phoneText);
panel.add(createAccountButton);
}
private void insertUserToDatabase(String name, String email, String password, String phone)
throws SQLException {
Connection conn = null;
PreparedStatement preparedStatement = null;
String sql = "INSERT INTO Users (Name, Email, Password, Phone) VALUES (?, ?, ?, ?)";
try {
Class.forName(JDBC_DRIVER);
conn = DriverManager.getConnection(DATABASE_URL, DATABASE_USER, DATABASE_PASSWORD);
preparedStatement = conn.prepareStatement(sql);
preparedStatement.setString(1, name);
preparedStatement.setString(2, email);
preparedStatement.setString(3, password);
preparedStatement.setString(4, phone);
int affectedRows = preparedStatement.executeUpdate();
if (affectedRows > 0) {
JOptionPane.showMessageDialog(this, "User added successfully!");
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
} finally {
if (preparedStatement != null) {
preparedStatement.close();
}
if (conn != null) {
conn.close();
}
}
}
}
class Update extends JFrame {
private JLabel jLabel1, jLabel2, jLabel3;
private JButton jButton1, jButton2;
private JPasswordField jPasswordField1, jPasswordField2;
public Update() {
setTitle("Update Password");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(400, 300);
setLocationRelativeTo(null);
initComponents();
}
private void initComponents() {
jLabel1 = new JLabel("Update Password");
jLabel2 = new JLabel("Enter new password");
jLabel3 = new JLabel("Confirm new password");
jButton1 = new JButton("Confirm Update");
jButton2 = new JButton("Back");
jPasswordField1 = new JPasswordField(20);
jPasswordField2 = new JPasswordField(20);
jButton1.addActionListener(this::jButton1ActionPerformed);
jButton2.addActionListener(e -> this.dispose());
JPanel panel = new JPanel(new GridLayout(4, 2));
panel.add(jLabel1);
panel.add(new JLabel(""));
panel.add(jLabel2);
panel.add(jPasswordField1);
panel.add(jLabel3);
panel.add(jPasswordField2);
panel.add(jButton1);
panel.add(jButton2);
add(panel);
}
private void jButton1ActionPerformed(ActionEvent evt) {
String pass = new String(jPasswordField1.getPassword());
String cpass = new String(jPasswordField2.getPassword());
if (pass.isEmpty() || cpass.isEmpty()) {
JOptionPane.showMessageDialog(this, "Fields can't be empty");
jPasswordField1.setText("");
jPasswordField2.setText("");
} else if (!pass.equals(cpass)) {
JOptionPane.showMessageDialog(this, "Passwords do not match");
} else {
updatePassword(pass);
}
}
private void updatePassword(String newPassword) {
String url = "jdbc:mysql://localhost:3306/MTG";
String username = "root";
String password = "System";
try (Connection conn = DriverManager.getConnection(url, username, password);
PreparedStatement stmt = conn
.prepareStatement("UPDATE Users SET Password = ? WHERE Username = ?")) {
stmt.setString(1, newPassword);
stmt.setString(2, "CurrentUsername");
int affected = stmt.executeUpdate();
if (affected > 0) {
JOptionPane.showMessageDialog(this, "Password updated successfully.");
dispose();
} else {
JOptionPane.showMessageDialog(this, "Failed to update password.");
}
} catch (SQLException e) {
JOptionPane.showMessageDialog(this, "Database error: " + e.getMessage());
}
}
}
// end of login
class PlannerApp extends JFrame {
MainApplication mainApp;
public PlannerApp(MainApplication mainApp) {
this.mainApp = mainApp;
setTitle("My Tour Guide ");
setSize(300, 200);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setLocationRelativeTo(null);
setLayout(new FlowLayout());
JLabel welcomeLabel = new JLabel("Welcome to our planner");
JButton startButton = new JButton("Start Homepage");
ImageIcon logoIcon = new ImageIcon("logo.jpeg");
Image image = logoIcon.getImage();
Image newimg = image.getScaledInstance(100, 100, java.awt.Image.SCALE_DEFAULT);
logoIcon = new ImageIcon(newimg);
JLabel logoLabel = new JLabel(logoIcon);
startButton.addActionListener(e -> {
mainApp.showHomepage();
dispose();
});
add(logoLabel);
add(welcomeLabel);
add(startButton);
}
}
class Homepage extends JFrame {
MainApplication mainApp;
public Homepage(MainApplication mainApp) {
this.mainApp = mainApp;
setTitle("Homepage");
setSize(400, 250);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setLocationRelativeTo(null);
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new GridLayout(0, 2));
add(mainPanel, BorderLayout.CENTER);
JPanel leftPanel = new JPanel(new GridLayout(5, 1));
mainPanel.add(leftPanel, BorderLayout.WEST);
JPanel rightPanel = new JPanel(new GridLayout(5, 1));
mainPanel.add(rightPanel, BorderLayout.EAST);
JPanel centerPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
mainPanel.add(centerPanel, BorderLayout.PAGE_END);
JButton newTripButton = new JButton("New Trip");
newTripButton.addActionListener(e -> {
TripGUI tripGUI = new TripGUI();
tripGUI.setVisible(true);
});
JButton infoButton = new JButton("My Info");
infoButton.addActionListener(e -> {
DatabaseManagerGUI infoGUI = new DatabaseManagerGUI();
infoGUI.setVisible(true);
});
JButton ordersButton = new JButton("Orders");
ordersButton.addActionListener(e -> {
OrderQueryGUI orderGUI = new OrderQueryGUI();
orderGUI.setVisible(true);
});
JButton imageButton = new JButton("Images");
imageButton.addActionListener(e -> {
ImageBrowser imageBrowser = new ImageBrowser();
imageBrowser.setVisible(true);
});
JButton tripButton = new JButton("Trip");
tripButton.addActionListener(e -> {
TripDisplayGUI tripQueryManager = new TripDisplayGUI();
tripQueryManager.setVisible(true);
});
leftPanel.add(newTripButton);
leftPanel.add(infoButton);
leftPanel.add(ordersButton);
leftPanel.add(imageButton);
leftPanel.add(tripButton);
// Right Panel Buttons
JButton priceButton = new JButton("Price Menu");
priceButton.addActionListener(e -> {
TourGuiApp priceTable = new TourGuiApp();
priceTable.setVisible(true);
});
JButton offersButton = new JButton("Offers");
offersButton.addActionListener(e -> {
DiscountGUI discountGUI = new DiscountGUI();
discountGUI.setVisible(true);
});
JButton carsButton = new JButton("Transaction");
carsButton.addActionListener(e -> {
DeliveryQueryGUI transactionGUI = new DeliveryQueryGUI();
transactionGUI.setVisible(true);
});
JButton passwButton = new JButton("Update PW");
passwButton.addActionListener(e -> {
Update updatePasswordGUI = new Update();
updatePasswordGUI.setVisible(true);
});
JButton helpButton = new JButton("Help");
helpButton.addActionListener(e -> {
ITIssueLoggerGUI itIssueLoggerGUI = new ITIssueLoggerGUI();
itIssueLoggerGUI.setVisible(true);
});
rightPanel.add(priceButton);
rightPanel.add(offersButton);
rightPanel.add(carsButton);
rightPanel.add(passwButton);
rightPanel.add(helpButton);
JButton logoutButton = new JButton("Logout");
logoutButton.addActionListener(e -> {
dispose();
});
JPanel logoutPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
logoutPanel.add(logoutButton);
add(logoutPanel, BorderLayout.PAGE_END);
}
}
// all user verification classes
// GUI PART
// Booking step(asayel+norah+batool+lama)
// Asayel Gui
class TripGUI extends JFrame {
private JButton saveButton, backButton;
private JComboBox<String> cityComboBox;
private JLabel selectCityLabel, departOnLabel, adultsLabel, childrenLabel, infantsLabel;
private JSpinner adultsSpinner, childrenSpinner, infantsSpinner;
private JTextField dayField, monthField, yearField;
public TripGUI() {
initComponents();
setupLayout();
setupListeners();
}
private void initComponents() {
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setTitle("Booking tourism");
selectCityLabel = new JLabel("Select City:");
departOnLabel = new JLabel("Depart on:");
adultsLabel = new JLabel("Adults (>12 yrs):");
childrenLabel = new JLabel("Children (2-11 yrs):");
infantsLabel = new JLabel("Infants (<2 yrs):");
String[] cities = { "Abha", "Alula", "Eastern Province", "Jeddah", "Riyadh" };
cityComboBox = new JComboBox<>(cities);
dayField = new JTextField("DD", 2);
monthField = new JTextField("MM", 2);
yearField = new JTextField("YYYY", 4);
adultsSpinner = new JSpinner(new SpinnerNumberModel(1, 0, 10, 1));
childrenSpinner = new JSpinner(new SpinnerNumberModel(0, 0, 10, 1));
infantsSpinner = new JSpinner(new SpinnerNumberModel(0, 0, 10, 1));
saveButton = new JButton("Save");
backButton = new JButton("Back");
}
private void setupLayout() {
GroupLayout layout = new GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setAutoCreateGaps(true);
layout.setAutoCreateContainerGaps(true);
layout.setHorizontalGroup(
layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(selectCityLabel)
.addComponent(cityComboBox, GroupLayout.PREFERRED_SIZE, 150,
GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(departOnLabel)
.addGroup(layout.createSequentialGroup()
.addComponent(dayField, GroupLayout.PREFERRED_SIZE, 50,
GroupLayout.PREFERRED_SIZE)
.addComponent(monthField, GroupLayout.PREFERRED_SIZE, 50,
GroupLayout.PREFERRED_SIZE)
.addComponent(yearField, GroupLayout.PREFERRED_SIZE, 50,
GroupLayout.PREFERRED_SIZE))
.addComponent(adultsLabel)
.addComponent(adultsSpinner, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE)
.addComponent(childrenLabel)
.addComponent(childrenSpinner, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE)
.addComponent(infantsLabel)
.addComponent(infantsSpinner, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE)
.addComponent(saveButton))
.addComponent(backButton));
layout.setVerticalGroup(
layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(selectCityLabel)
.addComponent(departOnLabel))
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(cityComboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE)
.addComponent(dayField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE)
.addComponent(monthField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE)
.addComponent(yearField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE))
.addComponent(adultsLabel)
.addComponent(adultsSpinner, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE)
.addComponent(childrenLabel)
.addComponent(childrenSpinner, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE)
.addComponent(infantsLabel)
.addComponent(infantsSpinner, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(saveButton)
.addComponent(backButton)));
pack();
setLocationRelativeTo(null); // Center on screen
}
private void setupListeners() {
cityComboBox.addActionListener(e -> {
String selectedCity = (String) cityComboBox.getSelectedItem();
showCityGuide(selectedCity);
});
saveButton.addActionListener(this::onSave);
backButton.addActionListener(e -> dispose());
}
private void onSave(ActionEvent evt) {
try {
String city = (String) cityComboBox.getSelectedItem();
int day = Integer.parseInt(dayField.getText().trim());
int month = Integer.parseInt(monthField.getText().trim());
int year = Integer.parseInt(yearField.getText().trim());
LocalDate startDate;
try {
startDate = LocalDate.of(year, month, day);
if (startDate.isBefore(LocalDate.now())) {
JOptionPane.showMessageDialog(this, "The date must not be in the past.", "Date Error",
JOptionPane.ERROR_MESSAGE);
return;
}
} catch (DateTimeException e) {
JOptionPane.showMessageDialog(this, "Please enter a valid future date.", "Date Error",
JOptionPane.ERROR_MESSAGE);
return;
}
int adults = (int) adultsSpinner.getValue();
int children = (int) childrenSpinner.getValue();
int infants = (int) infantsSpinner.getValue();
if (adults < 0 || children < 0 || infants < 0) {
JOptionPane.showMessageDialog(this, "Number of adults, children, and infants must be non-negative.",
"Number Error", JOptionPane.ERROR_MESSAGE);
return;
}
openPersonalInformationGui(adults, children, infants);
JOptionPane.showMessageDialog(this,
"Booking details saved successfully! Please fill in personal information.", "Success",
JOptionPane.INFORMATION_MESSAGE);
} catch (NumberFormatException ex) {
JOptionPane.showMessageDialog(this,
"Please check your input values. Numbers are expected for day, month, year, adults, children, and infants.",
"Input Error", JOptionPane.ERROR_MESSAGE);
}
}
private void openPersonalInformationGui(int adults, int children, int infants) {
for (int i = 0; i < adults; i++) {
new PersonalInformationGUI("Adult " + (i + 1)).setVisible(true);
}
for (int i = 0; i < children; i++) {
new PersonalInformationGUI("Child " + (i + 1)).setVisible(true);
}
for (int i = 0; i < infants; i++) {
new PersonalInformationGUI("Infant " + (i + 1)).setVisible(true);
}
}
private void showCityGuide(String city) {
JFrame cityGuide = null;
switch (city) {
case "Abha":
cityGuide = new AbhaGUI();
cityGuide.setVisible(true);
break;
case "Alula":
cityGuide = new AlulaGUI();
cityGuide.setVisible(true);
break;
case "Eastern Province":
cityGuide = new EasternProvinceGUI();
cityGuide.setVisible(true);
break;
case "Jeddah":
cityGuide = new JeddahGUI();
cityGuide.setVisible(true);
break;
case "Riyadh":
cityGuide = new RiyadhGUI();
cityGuide.setVisible(true);
break;
}
}
}
// Norah gui's
class RiyadhGUI extends JFrame {
private JLabel titleLabel;
private JTable activityTable;
private JTable shoppingTable;
private JTextArea safetyTipsTextArea;
public RiyadhGUI() {
setTitle("Riyadh City Guide");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(800, 600);
titleLabel = new JLabel("Riyadh City Guide");
titleLabel.setFont(new Font("Arial", Font.BOLD, 25));
titleLabel.setHorizontalAlignment(JLabel.CENTER);
String[] activityColumnNames = { "Day", "Activities" };
Object[][] activityData = {
{ "Day 1",
"1-Breakfast(hotel)\n 2-Kingdom Suspension Bridge\n 3-Riyadh Park\n 4-Beef Bar Restaurant" },
{ "Day 2", "1-Lovefer Branch\n 2-Cinema (Boulevard)\n 3-Meraki Restuarant" },
{ "Day 3", "Free Day" },
{ "Day 4", "1-Rishshaw London Branch\n 2-Winter Wonderland\n 3-PizzaBar Restaurant" },
{ "Day 5", "1-Breakfast(hotel)\n 2-Al-Nakheel Mall\n3-Oia Restuarant" },
{ "Day 6", "1-Easy Bakery Branch\n 2-Dalila Camp Event" },
{ "Day 7", "1-Breakfast(hotel)\n 2-KingAbdullah Financial District\n3-Al-Nakheel Mall" }
};
activityTable = new JTable(activityData, activityColumnNames);
JScrollPane activityScrollPane = new JScrollPane(activityTable);
String[] shoppingColumnNames = { "Day", "Shopping" };
Object[][] shoppingData = {
{ "Day 1", "1-F60r Branch\n 2-KingAbdullah Park\n 3-Riyadh Front" },
{ "Day 2", "1-Breakfast(hotel)\n 2-Winter Wonderland\n 3-Sign Restuarant" },
{ "Day 3", "1-Breakfast(hotel)\n 2-Historic Murabba Palace\n 3-Roor Restuarant" },
{ "Day 4", "1-Arkmi Restuarant\n 2-Al-Nakheel Mall\n 3-Riyadh Zoo\n 4-Roasted Way Restuarant" },
{ "Day 5", "Free Day" },
{ "Day 6", "1-Salam Park\n 2-Suspension Bridge\n 3-Urban Restuarant" },
{ "Day 7", "\n1-KingAbdullah Financial Districtn\n2- Kingdom Suspension Bridge" }
};
shoppingTable = new JTable(shoppingData, shoppingColumnNames);
JScrollPane shoppingScrollPane = new JScrollPane(shoppingTable);
safetyTipsTextArea = new JTextArea();
safetyTipsTextArea.setEditable(false);
safetyTipsTextArea.setText("Safety Tips:\n" +
"- Be cautious of your belongings in crowded areas.\n" +
"- Dress modestly and respect local customs.\n" +
"- Drink plenty of water to stay hydrated, especially during hot weather.");
JButton modifyButton = new JButton("Rotate Schedule");
modifyButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int confirmed = JOptionPane.showConfirmDialog(null,
"Are you sure you want to rotate the schedule?", "Confirmation", JOptionPane.YES_NO_OPTION);
if (confirmed == JOptionPane.YES_OPTION) {
rotateSchedule(activityData, shoppingData);
activityTable.repaint();
shoppingTable.repaint();
JOptionPane.showMessageDialog(null, "Schedule rotated successfully!");
}
}
});
JPanel mainPanel = new JPanel(new GridLayout(4, 1));
mainPanel.add(titleLabel);
mainPanel.add(activityScrollPane);
mainPanel.add(shoppingScrollPane);
mainPanel.add(modifyButton);
getContentPane().add(mainPanel, BorderLayout.CENTER);
getContentPane().add(safetyTipsTextArea, BorderLayout.SOUTH);
}
private void rotateSchedule(Object[][] activityData, Object[][] shoppingData) {
Object[] tempActivity = activityData[activityData.length - 1];
System.arraycopy(activityData, 0, activityData, 1, activityData.length - 1);
activityData[0] = tempActivity;
Object[] tempShopping = shoppingData[shoppingData.length - 1];
System.arraycopy(shoppingData, 0, shoppingData, 1, shoppingData.length - 1);
shoppingData[0] = tempShopping;
}
}
class JeddahGUI extends JFrame {
private JLabel titleLabel;
private JTable activityTable;
private JTable shoppingTable;
private JTextArea safetyTipsTextArea;
public JeddahGUI() {
setTitle("Jeddah City Guide");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(800, 600);
titleLabel = new JLabel("Jeddah City Guide");
titleLabel.setFont(new Font("Arial", Font.BOLD, 25));
titleLabel.setHorizontalAlignment(JLabel.CENTER);
String[] activityColumnNames = { "Day", "Activities" };
Object[][] activityData = {
{ "Day 1",
"1-Caffeine Lab Branch\n 2-BROOTS Coffee & Cocoaln\n 3-ALshallal\n 4-Atallah Happy Land ParkIn" },
{ "Day 2", "1-Al-Tayebat international city\n 2-Maqadeer Restuarant\n3-Fakieh Aquarium" },
{ "Day 3", "Free Day" },
{ "Day 4", "1-THE YEMENI VILLAE\n 2-Thoul BeachIn\n 3-Tayebat internatio" },
{ "Day 5",
"1-American Corner Restuarant\n 2-Zillion Restuarant\n 3-San Carlo Cicchetti Restuarant" },
{ "Day 6", "1-San Carlo Cicchetti Restuarant\n 2-Hemi Cafe & Roastrey " },
{ "Day 7", "1-Breakfast(hotel)\n2-KingAbdullah Financial District\n 3-Zillion Restuarant" }
};
activityTable = new JTable(activityData, activityColumnNames);
JScrollPane activityScrollPane = new JScrollPane(activityTable);
String[] shoppingColumnNames = { "Day", "Shopping" };
Object[][] shoppingData = {
{ "Day 1", "1-Mall of Arabia\n 2-Serafi Mega Mall\n 3-Aziz Mall" },
{ "Day 2", "1-Aziz Mall\n 2-Le Chateau Mall\n 3-Boulevard" },
{ "Day 3", "1-El Khayyat Center\n 2-Ana Special Mall\n 3-Haifaa Mall" },
{ "Day 4", "1-Stars Avenue Mall\n 2-Andalus Mall\n 3-Jeddahmall\n 4-Al Salaam Mall" },
{ "Day 5", "Free Day" },
{ "Day 6", "1-Roshan Mall\n 2-Flamengo Park\n 3-Jeddah Park" },
{ "Day 7", "\n1-Yasmin Mall" }
};
shoppingTable = new JTable(shoppingData, shoppingColumnNames);
JScrollPane shoppingScrollPane = new JScrollPane(shoppingTable);
safetyTipsTextArea = new JTextArea();
safetyTipsTextArea.setEditable(false);
safetyTipsTextArea.setText("Safety Tips:\n" +
"- Be cautious of your belongings in crowded areas.\n" +
"- Dress modestly and respect local customs.\n" +
"- Drink plenty of water to stay hydrated, especially during hot weather.");
JButton modifyButton = new JButton("Rotate Schedule");
modifyButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int confirmed = JOptionPane.showConfirmDialog(null,
"Are you sure you want to rotate the schedule?", "Confirmation", JOptionPane.YES_NO_OPTION);
if (confirmed == JOptionPane.YES_OPTION) {
rotateSchedule(activityData, shoppingData);
activityTable.repaint();
shoppingTable.repaint();
JOptionPane.showMessageDialog(null, "Schedule rotated successfully!");
}
}
});
JPanel mainPanel = new JPanel(new GridLayout(4, 1));
mainPanel.add(titleLabel);
mainPanel.add(activityScrollPane);
mainPanel.add(shoppingScrollPane);
mainPanel.add(modifyButton);
getContentPane().add(mainPanel, BorderLayout.CENTER);
getContentPane().add(safetyTipsTextArea, BorderLayout.SOUTH);
}
private void rotateSchedule(Object[][] activityData, Object[][] shoppingData) {
Object[] tempActivity = activityData[activityData.length - 1];
System.arraycopy(activityData, 0, activityData, 1, activityData.length - 1);
activityData[0] = tempActivity;
Object[] tempShopping = shoppingData[shoppingData.length - 1];
System.arraycopy(shoppingData, 0, shoppingData, 1, shoppingData.length - 1);
shoppingData[0] = tempShopping;
}
}
class AlulaGUI extends JFrame {
private JLabel titleLabel;
private JTable activityTable;
private JTable shoppingTable;
private JTextArea safetyTipsTextArea;
public AlulaGUI() {
setTitle("Alula City Guide");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(800, 600);
titleLabel = new JLabel("Alula City Guide");
titleLabel.setFont(new Font("Arial", Font.BOLD, 25));
titleLabel.setHorizontalAlignment(JLabel.CENTER);
String[] activityColumnNames = { "Day", "Activities" };
Object[][] activityData = {
{ "Day 1", "1-The old city of AlUla\n 2-AlUla Museum\n 3-Go to the hotel (AlUla Mirrors)" },
{ "Day 2", "1-Have dinner at Al Diwan Restaurant\n 2-Madain Saleh\n 3-AlUla Oasis" },
{ "Day 3", "Free Day" },
{ "Day 4",
"1-Al Manara Restaurant\n 2-Elephant Rock: Take a tour to see the unique rock formation that resembles an elephant" },
{ "Day 5", "1-Have dinner at Al Khaira Restaurant\n 2-Old railway station" },
{ "Day 6", "1-Enjoy activities like horse riding\n 2-Fayrouz Restaurant " },
{ "Day 7",
"1-Go to AlUlA Desert Resort\n 2-KingAbdullah Financial District\n 3-Zillion Restuarant" }
};
activityTable = new JTable(activityData, activityColumnNames);
JScrollPane activityScrollPane = new JScrollPane(activityTable);
safetyTipsTextArea = new JTextArea();
safetyTipsTextArea.setEditable(false);
safetyTipsTextArea.setText("Safety Tips:\n" +
"- Be cautious of your belongings in crowded areas.\n" +
"- Dress modestly and respect local customs.\n" +
"- Drink plenty of water to stay hydrated, especially during hot weather.");
JButton modifyButton = new JButton("Rotate Schedule");
modifyButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int confirmed = JOptionPane.showConfirmDialog(null,
"Are you sure you want to rotate the schedule?", "Confirmation", JOptionPane.YES_NO_OPTION);
if (confirmed == JOptionPane.YES_OPTION) {
rotateSchedule(activityData, null);
activityTable.repaint();
JOptionPane.showMessageDialog(null, "Schedule rotated successfully!");
}
}
});
JPanel mainPanel = new JPanel(new GridLayout(4, 1));
mainPanel.add(titleLabel);
mainPanel.add(activityScrollPane);
mainPanel.add(modifyButton);
getContentPane().add(mainPanel, BorderLayout.CENTER);
getContentPane().add(safetyTipsTextArea, BorderLayout.SOUTH);
}
private void rotateSchedule(Object[][] activityData, Object[][] shoppingData) {
Object[] tempActivity = activityData[activityData.length - 1];
System.arraycopy(activityData, 0, activityData, 1, activityData.length - 1);
activityData[0] = tempActivity;
}
}
class AbhaGUI extends JFrame {
private JLabel titleLabel;
private JTable activityTable;
private JTable shoppingTable;
private JTextArea safetyTipsTextArea;
public AbhaGUI() {
setTitle("Abha City Guide");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(800, 600);
titleLabel = new JLabel("Abha City Guide");
titleLabel.setFont(new Font("Arial", Font.BOLD, 25));
titleLabel.setHorizontalAlignment(JLabel.CENTER);
String[] activityColumnNames = { "Day", "Activities" };
Object[][] activityData = {
{ "Day 1", "1-Verde Restuarant \n 2-Abu Kheyal\n 3-Giorno Coffe" },
{ "Day 2", "1-Le Voyage Restuarant\n 2-Aya Sofy\n 3-VotelSt" },
{ "Day 3", "Free Day" },
{ "Day 4", "1-View Cafe\n 2-Al-Sahab Park\n 3-Black Box Cafe" },
{ "Day 5", "1-Ala Bali Restuarant\n 2-Damside Park\n 3-The Dabbab Walkway" },
{ "Day 6", "1-Tonir Restuarant\n 2-The Dabbab Walkway " },
{ "Day 7", "1-Will Cafe\n 2-VotelSt\n 3-Giorno Coffe" }
};
activityTable = new JTable(activityData, activityColumnNames);
JScrollPane activityScrollPane = new JScrollPane(activityTable);
String[] shoppingColumnNames = { "Day", "Shopping" };
Object[][] shoppingData = {
{ "Day 1", "Aseer Mall\n" },
{ "Day 2", "Rihanna Mall\n" },
{ "Day 3", "Al Nakheel " },
{ "Day 4", "Abha Mall\n " },
{ "Day 5", "Free Day" },
{ "Day 6", "Ravala Plaza\n" },
{ "Day 7", "Al Rashid Mall" }
};
shoppingTable = new JTable(shoppingData, shoppingColumnNames);
JScrollPane shoppingScrollPane = new JScrollPane(shoppingTable);
safetyTipsTextArea = new JTextArea();
safetyTipsTextArea.setEditable(false);
safetyTipsTextArea.setText("Safety Tips:\n" +
"- Be cautious of your belongings in crowded areas.\n" +
"- Dress modestly and respect local customs.\n" +
"- Drink plenty of water to stay hydrated, especially during hot weather.");
JButton modifyButton = new JButton("Rotate Schedule");
modifyButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int confirmed = JOptionPane.showConfirmDialog(null,
"Are you sure you want to rotate the schedule?", "Confirmation", JOptionPane.YES_NO_OPTION);
if (confirmed == JOptionPane.YES_OPTION) {
rotateSchedule(activityData, shoppingData);
activityTable.repaint();
shoppingTable.repaint();
JOptionPane.showMessageDialog(null, "Schedule rotated successfully!");
}
}
});
JPanel mainPanel = new JPanel(new GridLayout(4, 1));
mainPanel.add(titleLabel);
mainPanel.add(activityScrollPane);
mainPanel.add(shoppingScrollPane);
mainPanel.add(modifyButton);
getContentPane().add(mainPanel, BorderLayout.CENTER);
getContentPane().add(safetyTipsTextArea, BorderLayout.SOUTH);
}
private void rotateSchedule(Object[][] activityData, Object[][] shoppingData) {
Object[] tempActivity = activityData[activityData.length - 1];
System.arraycopy(activityData, 0, activityData, 1, activityData.length - 1);
activityData[0] = tempActivity;
Object[] tempShopping = shoppingData[shoppingData.length - 1];
System.arraycopy(shoppingData, 0, shoppingData, 1, shoppingData.length - 1);
shoppingData[0] = tempShopping;
}
}
class EasternProvinceGUI extends JFrame {
private JLabel titleLabel;
private JTable activityTable;
private JTable shoppingTable;
private JTextArea safetyTipsTextArea;
public EasternProvinceGUI() {
setTitle("EasternProvince Guide");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(800, 600);
titleLabel = new JLabel("EasternProvince Guide");
titleLabel.setFont(new Font("Arial", Font.BOLD, 25));
titleLabel.setHorizontalAlignment(JLabel.CENTER);
String[] activityColumnNames = { "Day", "Activities" };
Object[][] activityData = {
{ "Day 1",
"1-Arrival to Dammam Airport and entry to the (Sheraton Hotel)\n 2-Kingdom Suspension Bridge\n 3-Have breakfast at the hotel\n 4-Have lunch at( Lumiere) Restaurant" },
{ "Day 2",
"1-Have breakfast at the hotel\n 2-Go to( Paul Gardenia) Resort in Al Khobar and spend the day there\n 3-Meraki Restuarant" },
{ "Day 3", "Free Day" },
{ "Day 4",
"1-Have breakfast at (Solas )Restaurant\n 2-Ithra visit\n 3-Watch a movie at (Ajdan Walk Cinema)" },
{ "Day 5", "1-Have breakfast at the hotel\n 2-Have dinner and cofe at (City Walk)" },
{ "Day 6",
"1-Have lunch at (Parkers) Restaurant\n 2-Go to Deghaithir Island and enjoy the food and scenery" },
{ "Day 7",
"1-Breakfast(hotel)\n 2-Have dinner at (Miso) Restaurant\n 3-Visit (Loupage) Water Games" }
};
activityTable = new JTable(activityData, activityColumnNames);
JScrollPane activityScrollPane = new JScrollPane(activityTable);
String[] shoppingColumnNames = { "Day", "Shopping" };
Object[][] shoppingData = {
{ "Day 1", "Al Rashid Mall" },
{ "Day 2", "Dareen Mall Dammam " },
{ "Day 3", "Beach Mall Dammam or Marina Mall Dammam" },
{ "Day 4", "Al Khobar Mall Center" },
{ "Day 5", "Free Day" },
{ "Day 6", "Dhahran Mall" },
{ "Day 7", "Nakheel Mall Dammam" }
};
shoppingTable = new JTable(shoppingData, shoppingColumnNames);
JScrollPane shoppingScrollPane = new JScrollPane(shoppingTable);
safetyTipsTextArea = new JTextArea();
safetyTipsTextArea.setEditable(false);
safetyTipsTextArea.setText("Safety Tips:\n" +
"- Be cautious of your belongings in crowded areas.\n" +
"- Dress modestly and respect local customs.\n" +
"- Drink plenty of water to stay hydrated, especially during hot weather.");
JButton modifyButton = new JButton("Rotate Schedule");
modifyButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int confirmed = JOptionPane.showConfirmDialog(null,
"Are you sure you want to rotate the schedule?", "Confirmation", JOptionPane.YES_NO_OPTION);
if (confirmed == JOptionPane.YES_OPTION) {
rotateSchedule(activityData, shoppingData);
activityTable.repaint();
shoppingTable.repaint();
JOptionPane.showMessageDialog(null, "Schedule rotated successfully!");
}
}
});
JPanel mainPanel = new JPanel(new GridLayout(4, 1));
mainPanel.add(titleLabel);
mainPanel.add(activityScrollPane);
mainPanel.add(shoppingScrollPane);
mainPanel.add(modifyButton);
getContentPane().add(mainPanel, BorderLayout.CENTER);
getContentPane().add(safetyTipsTextArea, BorderLayout.SOUTH);
}
private void rotateSchedule(Object[][] activityData, Object[][] shoppingData) {
Object[] tempActivity = activityData[activityData.length - 1];
System.arraycopy(activityData, 0, activityData, 1, activityData.length - 1);
activityData[0] = tempActivity;
Object[] tempShopping = shoppingData[shoppingData.length - 1];
System.arraycopy(shoppingData, 0, shoppingData, 1, shoppingData.length - 1);
shoppingData[0] = tempShopping;
}