C:\Users\Man\Desktop\IA_FinaL_Submission_000307-0092\Product\IA_Netbeans_Project\src\ia\man\Main.java |
1
2
3
4
5
6 package ia.man;
7
8
9 import chrriis.common.UIUtils;
10 import chrriis.dj.nativeswing.swtimpl.NativeInterface;
11 import chrriis.dj.nativeswing.swtimpl.components.JWebBrowser;
12
13 import java.awt.Color;
14 import java.awt.Container;
15 import java.awt.Dimension;
16 import java.awt.Toolkit;
17 import java.awt.event.WindowAdapter;
18 import java.awt.event.WindowEvent;
19 import java.awt.BorderLayout;
20 import java.awt.FlowLayout;
21 import java.awt.event.ItemEvent;
22 import java.awt.event.ItemListener;
23 import java.io.BufferedReader;
24 import java.io.BufferedWriter;
25 import java.io.File;
26 import java.io.FileReader;
27 import java.io.FileWriter;
28 import java.io.IOException;
29 import java.net.MalformedURLException;
30 import java.net.URL;
31 import java.text.DateFormat;
32 import java.text.SimpleDateFormat;
33 import java.util.Date;
34 import java.util.logging.Level;
35 import java.util.logging.Logger;
36 import javax.swing.BorderFactory;
37 import javax.swing.JOptionPane;
38 import javax.swing.table.DefaultTableModel;
39 import javafx.application.Platform;
40 import javafx.embed.swing.JFXPanel;
41 import javafx.scene.Group;
42 import javafx.scene.Scene;
43 import javafx.scene.text.Font;
44 import javafx.scene.text.Text;
45 import javafx.scene.web.WebEngine;
46 import javafx.scene.web.WebView;
47 import javax.swing.JCheckBox;
48 import javax.swing.JComponent;
49 import javax.swing.JFrame;
50 import javax.swing.JPanel;
51 import javax.swing.WindowConstants;
52 import javax.swing.JTextPane;
53 import javax.swing.SwingUtilities;
54
55
56
57 @author
58
59 public class Main extends javax.swing.JFrame {
60
61
62
63
64
65 User iUser = new User();
66
67 Main() {
68 throw new UnsupportedOperationException("Not supported yet.");
69 }
70
71 public Main(String id,String user,String email,String pass) throws IOException {
72
73 initComponents();
74 panel1.add(createContent());
75
76 iUser.AssingValue(id, user, email, pass);
77
78 Toolkit toolkit = getToolkit();
79 Dimension size = toolkit.getScreenSize();
80 setLocation(size.width/2 - getWidth()/2, size.height/2 - getHeight()/2);
81
82 DateFormat dateFormat = new SimpleDateFormat("MM-dd");
83 DateFormat yearFormat = new SimpleDateFormat("yyyy");
84 Date date = new Date();
85
86 String year = yearFormat.format(date);
87 int bc_year = Integer.parseInt(year) - 543;
88
89 String Current_Date = String.valueOf(bc_year) + "-" + dateFormat.format(date);
90
91 lblDate.setText(Current_Date);
92
93 setTitle(user);
94 getInfo(id,user,email,pass);
95
96
97 new Thread(() ->
98 {
99 while(true)
100 {
101 checkReady(lblDate.getText());
102 try {
103 Thread.sleep(500);
104 } catch (InterruptedException ex) {
105 Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
106 }
107 }
108 }).start();
109
110 }
111
112
385
386 String id,user,email,pass;
387
388 id = iUser.getID();
389 user = iUser.getUser();
390 email = iUser.getEmail();
391 pass = iUser.getPass();
392
393 Planner planner = new Planner(id,user,email,pass);
394 planner.setVisible(true);
395
396 }
397
398
399 @param
400
401 public static void main(String args[]) {
402
403
404
405
406
407 try {
408 for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
409 if ("Nimbus".equals(info.getName())) {
410 javax.swing.UIManager.setLookAndFeel(info.getClassName());
411 break;
412 }
413 }
414 } catch (ClassNotFoundException ex) {
415 java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
416 } catch (InstantiationException ex) {
417 java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
418 } catch (IllegalAccessException ex) {
419 java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
420 } catch (javax.swing.UnsupportedLookAndFeelException ex) {
421 java.util.logging.Logger.getLogger(Main.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
422 }
423
424
425 NativeInterface.open();
426 UIUtils.setPreferredLookAndFeel();
427
428
429 SwingUtilities.invokeLater(new Runnable() {
430 public void run() {
431 new Main().setVisible(true);
432
433
434
435
436
437
438
439
440 }
441 });
442 NativeInterface.runEventPump();
443 }
444
445 public void setTitle(String name)
446 {
447 String title = null;
448 SimpleDateFormat dateFormat = new SimpleDateFormat("HH");
449 Date date = new Date();
450
451 if(Integer.parseInt(dateFormat.format(date)) >= 5 && Integer.parseInt(dateFormat.format(date)) < 12)
452 {
453 title = "Good Morning";
454 }
455 else if(Integer.parseInt(dateFormat.format(date)) >= 12 && Integer.parseInt(dateFormat.format(date)) < 17)
456 {
457 title = "Good Afternoon";
458 }
459 else
460 {
461 title = "Good Evening";
462 }
463
464 lblTitle.setText(title + " " + name);
465 }
466
467
468 public void getInfo(String id,String user,String email,String pass)
469 {
470 txtID.setText(id);
471 txtUser.setText(user);
472 txtEmail.setText(email);
473 txtPass.setText(pass);
474 }
475
476 public void updateData() throws IOException
477 {
478 String id,user,email,pass,line;
479
480 String pFile = "User.txt";
481 String pFileTemp = "User_temp.txt";
482
483 id = txtID.getText();
484 user = txtUser.getText();
485 email = txtEmail.getText();
486 pass = txtPass.getText();
487
488 int n = JOptionPane.showConfirmDialog(
489 null,
490 "Would you like green eggs and ham?",
491 "An Inane Question",
492 JOptionPane.YES_NO_OPTION);
493
494
495 if(n==0)
496 {
497 File File = new File(pFile);
498 File FileTemp = new File(pFileTemp);
499
500 BufferedWriter bw = new BufferedWriter( new FileWriter(FileTemp) );
501 BufferedReader br = new BufferedReader( new FileReader(File) );
502
503 while((line = br.readLine()) != null)
504 {
505 String[] arrFile = line.split("\\|");
506
507 if(arrFile[0].equals(id))
508 {
509 bw.write(id+"|"+user+"|"+email+"|"+pass);
510 }
511 else
512 {
513 bw.write(line);
514 }
515 bw.flush();
516 bw.newLine();
517 }
518
519 bw.close();
520 br.close();
521
522 File.delete();
523 boolean success = FileTemp.renameTo(File);
524 }
525 }
526
527 public void checkReady(String date)
528 {
529 String path = "Planner.txt";
530
531 File file = new File(path);
532
533 String line = null,
534 taskdate = null,
535 status = null;
536
537 try {
538
539
540
541 BufferedReader br = new BufferedReader(new FileReader(file));
542
543 int i = 0;
544 int allDone = 0;
545 while ((line = br.readLine()) != null)
546 {
547 String[] array = line.split("\\|");
548 taskdate = array[2];
549 status = array[7];
550
551 if(status.equals("No") && taskdate.equals(date))
552 {
553 allDone++;
554 i++;
555 }
556 array = null;
557 }
558 br.close();
559
560 if(allDone == 0)
561 {
562 lblReady.setVisible(true);
563 btnlol.setVisible(true);
564 }
565 else
566 {
567 lblReady.setVisible(false);
568 btnlol.setVisible(false);
569 lblReady.setForeground(Color.red);
570 lblReady.setForeground(Color.green);
571 lblReady.setForeground(Color.red);
572 lblReady.setForeground(Color.green);
573 lblReady.setForeground(Color.red);
574 lblReady.setForeground(Color.green);
575 lblReady.setForeground(Color.red);
576 }
577 } catch (IOException e) {
578 e.printStackTrace();
579 }
580 }
581
582
583 public static JComponent createContent() {
584
585 JPanel contentPane = new JPanel(new BorderLayout());
586 contentPane.setBounds(38, 34, 133, 92);
587
588 JPanel webBrowserPanel = new JPanel(new BorderLayout());
589 webBrowserPanel.setBorder(BorderFactory.createTitledBorder("Native Web Browser component"));
590 webBrowserPanel.setBounds(38, 34, 133, 92);
591
592 final JWebBrowser webBrowser = new JWebBrowser();
593 webBrowser.navigate("https://twitter.com");
594 webBrowserPanel.add(webBrowser);
595 contentPane.add(webBrowserPanel,BorderLayout.CENTER);
596
597 return contentPane;
598
599 }
600
601
602
603 // Variables declaration - do not modify
604 private javax.swing.JButton btnSave;
605 private javax.swing.JButton btnlol;
606 private javax.swing.JButton jButton10;
607 private javax.swing.JButton jButton3;
608 private javax.swing.JButton jButton4;
609 private javax.swing.JButton jButton6;
610 private javax.swing.JButton jButton7;
611 private javax.swing.JButton jButton8;
612 private javax.swing.JButton jButton9;
613 private javax.swing.JLabel jLabel1;
614 private javax.swing.JLabel jLabel2;
615 private javax.swing.JLabel jLabel3;
616 private javax.swing.JLabel jLabel4;
617 private javax.swing.JLabel jLabel5;
618 private javax.swing.JPanel jPanel1;
619 private javax.swing.JPanel jPanel2;
620 private javax.swing.JPanel jPanel3;
621 private javax.swing.JTabbedPane jTabbedPane1;
622 private javax.swing.JTabbedPane jTabbedPane2;
623 private javax.swing.JLabel lblDate;
624 private javax.swing.JLabel lblReady;
625 private javax.swing.JLabel lblTitle;
626 private java.awt.Panel panel1;
627 private javax.swing.JTextField txtEmail;
628 private javax.swing.JTextField txtID;
629 private javax.swing.JTextField txtPass;
630 private javax.swing.JTextField txtPassConfirm;
631 private javax.swing.JTextField txtUser;
632 // End of variables declaration
633 }
634
635