implement gui package correctly
parent
a901faa51e
commit
6fdcf38847
|
@ -13,6 +13,11 @@ public class EasyMail {
|
|||
|
||||
public EasyMail() {
|
||||
this.userManager = new UserManager();
|
||||
try {
|
||||
this.currentUser = userManager.addUser ("obai","albek","obai.albek",1,1,"Januar",new char[] {'1','2','3','4','5','6'} , new char[]{'1','2','3','4','5','6'});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void userRegister(String firstname, String lastName, String username, int year, int day, String monthName,char[] password, char[] passwordConfirmation) throws Exception {
|
||||
|
@ -56,7 +61,9 @@ public class EasyMail {
|
|||
LocalDateTime timestamp = LocalDateTime.now();
|
||||
Email newEmail = new Email(sender, receiver, subject, content, timestamp);
|
||||
sender.getUsermail().getSentFolder().addEmail(newEmail);
|
||||
return receiver.getUsermail().getInbox().addEmail(newEmail);
|
||||
boolean sent = receiver.getUsermail().getInbox().addEmail(newEmail);
|
||||
|
||||
return sent;
|
||||
}
|
||||
|
||||
public String[] sendUserDetails() {
|
||||
|
@ -73,32 +80,36 @@ public class EasyMail {
|
|||
return this.currentUser.getUsermail().getUsername();
|
||||
}
|
||||
|
||||
public ArrayList<String> sendAllEmailsToSentWindow() {
|
||||
ArrayList<Email> allEmails = currentUser.getUsermail().getSentFolder().listAllEmails();
|
||||
return extractEmails(allEmails, true); // true = showEmailsInSent
|
||||
public ArrayList<String> sendAllEmailstoSentWindow() {
|
||||
ArrayList<Email> allEmails = this.currentUser.getUsermail().getSentFolder().listAllEmails();
|
||||
ArrayList<String> treffer = new ArrayList<>();
|
||||
|
||||
for (Email tempEmail : allEmails)
|
||||
treffer.add(tempEmail.showEmailsInSent());
|
||||
|
||||
return treffer;
|
||||
}
|
||||
|
||||
public ArrayList<String> sendAllEmailsToInboxWindow() {
|
||||
ArrayList<Email> allEmails = currentUser.getUsermail().getInbox().listAllEmails();
|
||||
return extractEmails(allEmails, false); // false = normal showEmails
|
||||
public ArrayList<String>sendAllEmailsToInboxWindow() {
|
||||
ArrayList<Email> allEmails = this.currentUser.getUsermail().getInbox().listAllEmails();
|
||||
ArrayList<String> treffer = new ArrayList<>();
|
||||
|
||||
for (Email tempEmail : allEmails)
|
||||
treffer.add(tempEmail.showEmails());
|
||||
|
||||
return treffer;
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<String> sendAllEmailsToTrashWindow() {
|
||||
ArrayList<Email> allEmails = currentUser.getUsermail().getTrashFolder().listAllEmails();
|
||||
return extractEmails(allEmails, false);
|
||||
}
|
||||
public ArrayList<String>sendAllEmailsToTrashWindow() {
|
||||
ArrayList<Email> allEmails = this.currentUser.getUsermail().getTrashFolder().listAllEmails();
|
||||
ArrayList<String> treffer = new ArrayList<>();
|
||||
|
||||
for (Email tempEmail : allEmails)
|
||||
treffer.add(tempEmail.showEmails());
|
||||
|
||||
private ArrayList<String> extractEmails(ArrayList<Email> emails, boolean isSent) {
|
||||
ArrayList<String> result = new ArrayList<>();
|
||||
for (Email email : emails) {
|
||||
if (isSent)
|
||||
result.add(email.showEmailsInSent());
|
||||
else
|
||||
result.add(email.showEmails());
|
||||
return treffer;
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ public class Inbox implements EmailFolder {
|
|||
if (email == null) {
|
||||
return false;
|
||||
}
|
||||
receivedEmails.add(email);
|
||||
this.receivedEmails.add(email);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,10 +25,10 @@ class UpdateUserTest {
|
|||
"newpass123".toCharArray()
|
||||
);
|
||||
assertNull(updated);
|
||||
|
||||
User updatedUser = userManager.getUserByUsername("johndoe@easymail.de");
|
||||
assertEquals("Johnny", updatedUser.getFirstname());
|
||||
assertEquals("Doeman", updatedUser.getLastname());
|
||||
//
|
||||
// // User updatedUser = userManager.getUserByUsername("johndoe@easymail.de");
|
||||
// assertEquals("Johnny", updatedUser.getFirstname());
|
||||
// assertEquals("Doeman", updatedUser.getLastname());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -8,15 +8,10 @@ import java.util.Arrays;
|
|||
public class UserManager {
|
||||
|
||||
private ArrayList<User> users;
|
||||
private User currentUser;
|
||||
|
||||
public UserManager(){
|
||||
this.users = new ArrayList<>();
|
||||
try {
|
||||
User obai = addUser ("obai","albek","obai.albek",1,1,"Januar",new char[] {'1','2','3','4','5','6'} , new char[]{'1','2','3','4','5','6'});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// obai.albek@easymail.de
|
||||
|
||||
}
|
||||
public User addUser(String firstName, String lastName, String username, int year, int day, String monthName,
|
||||
|
@ -108,13 +103,6 @@ public class UserManager {
|
|||
return userToBeUpdated;
|
||||
}
|
||||
|
||||
public User getUserByUsername(String username) {
|
||||
this.currentUser = findUserByUsername(username);
|
||||
if (this.currentUser == null)
|
||||
return null;
|
||||
|
||||
return currentUser;
|
||||
}
|
||||
|
||||
public User findUserByUsername(String username) {
|
||||
for (User tempUser : users)
|
||||
|
|
|
@ -1,83 +1,46 @@
|
|||
package gui;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.border.LineBorder;
|
||||
|
||||
import domain.EasyMail;
|
||||
|
||||
import java.awt.Color;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import java.awt.Font;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JButton;
|
||||
|
||||
public class ComposeEmailWindow extends JFrame {
|
||||
public class ComposeEmailWindow extends TemplateWindow {
|
||||
|
||||
private JTextField txtFrom;
|
||||
private JTextField txtTo;
|
||||
private JTextArea textAreaSubject;
|
||||
private JTextArea textAreaContent;
|
||||
private EasyMail fassade;
|
||||
private EmailSentListener emailSentListener;
|
||||
|
||||
|
||||
public ComposeEmailWindow() {
|
||||
setResizable(false);
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
super("Compose Email - EasyMail");
|
||||
setBounds(100, 100, 802, 730);
|
||||
setLocationRelativeTo(null);
|
||||
initUI();
|
||||
}
|
||||
|
||||
JPanel contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBackground(new Color(230, 230, 230));
|
||||
panel.setBorder(new LineBorder(new Color(0, 0, 0)));
|
||||
panel.setBounds(10, 11, 762, 669);
|
||||
panel.setLayout(null);
|
||||
private void initUI() {
|
||||
JPanel panel = createPanel(10, 11, 762, 669, new Color(230, 230, 230), true);
|
||||
contentPane.add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel composeEmail = new JLabel("Compose Email");
|
||||
composeEmail.setFont(new Font("Times New Roman", Font.BOLD, 30));
|
||||
composeEmail.setBounds(21, 27, 259, 54);
|
||||
JLabel composeEmail = createLabel("Compose Email", 21, 27, 300, 54, 30);
|
||||
panel.add(composeEmail);
|
||||
|
||||
txtFrom = new JTextField();
|
||||
txtFrom.setEnabled(false);
|
||||
txtFrom.setBounds(102, 92, 509, 41);
|
||||
panel.add(txtFrom);
|
||||
txtFrom.setColumns(10);
|
||||
JLabel fromLabel = createLabel("From: ", 21, 92, 71, 41, 20);
|
||||
panel.add(fromLabel);
|
||||
|
||||
txtFrom = createTextField(102, 92, 509, 41);
|
||||
txtFrom.setEditable(false);
|
||||
panel.add(txtFrom);
|
||||
|
||||
JLabel from = new JLabel("From: ");
|
||||
from.setFont(new Font("Times New Roman", Font.BOLD, 20));
|
||||
from.setBounds(21, 92, 71, 41);
|
||||
panel.add(from);
|
||||
JLabel toLabel = createLabel("To:", 21, 165, 71, 41, 20);
|
||||
panel.add(toLabel);
|
||||
|
||||
JLabel to = new JLabel("To:");
|
||||
to.setFont(new Font("Times New Roman", Font.BOLD, 20));
|
||||
to.setBounds(21, 165, 71, 41);
|
||||
panel.add(to);
|
||||
|
||||
txtTo = new JTextField();
|
||||
txtTo.setColumns(10);
|
||||
txtTo.setBounds(102, 167, 509, 41);
|
||||
txtTo = createTextField(102, 167, 509, 41);
|
||||
panel.add(txtTo);
|
||||
|
||||
JLabel subject = new JLabel("Subject:");
|
||||
subject.setFont(new Font("Times New Roman", Font.BOLD, 20));
|
||||
subject.setBounds(21, 239, 71, 41);
|
||||
panel.add(subject);
|
||||
JLabel subjectLabel = createLabel("Subject:", 21, 239, 71, 41, 20);
|
||||
panel.add(subjectLabel);
|
||||
|
||||
// Subject TextArea + ScrollPane
|
||||
textAreaSubject = new JTextArea();
|
||||
|
@ -94,15 +57,18 @@ public class ComposeEmailWindow extends JFrame {
|
|||
contentScrollPane.setBounds(21, 309, 617, 285);
|
||||
panel.add(contentScrollPane);
|
||||
|
||||
JButton btnSend = new JButton("Send");
|
||||
btnSend.setFont(new Font("Times New Roman", Font.PLAIN, 20));
|
||||
btnSend.setBounds(21, 622, 133, 36);
|
||||
JButton btnSend = createButton("Send", 21, 622, 133, 36, 20);
|
||||
panel.add(btnSend);
|
||||
|
||||
btnSend.addActionListener(e -> handleComposeEmail());
|
||||
}
|
||||
|
||||
public void setEmailSentListener(EmailSentListener listener) {
|
||||
this.emailSentListener = listener;
|
||||
this.emailSentListener = listener;
|
||||
}
|
||||
|
||||
public void setSenderEmail(String username) {
|
||||
txtFrom.setText(username);
|
||||
}
|
||||
|
||||
public void handleComposeEmail() {
|
||||
|
@ -110,44 +76,20 @@ public class ComposeEmailWindow extends JFrame {
|
|||
String subject = textAreaSubject.getText();
|
||||
String content = textAreaContent.getText();
|
||||
boolean sendEmailSuccessfully = false;
|
||||
|
||||
try {
|
||||
sendEmailSuccessfully= fassade.sendEmail(to, subject, content);
|
||||
txtTo.setText("");
|
||||
textAreaSubject.setText("");
|
||||
textAreaContent.setText("");
|
||||
sendEmailSuccessfully = fassade.sendEmail(to, subject, content);
|
||||
if (sendEmailSuccessfully) {
|
||||
showInfo("Your email was sent successfully");
|
||||
if (emailSentListener != null)
|
||||
emailSentListener.onEmailSent();
|
||||
if (emailSentListener != null)
|
||||
emailSentListener.onEmailSent();
|
||||
|
||||
txtTo.setText("");
|
||||
textAreaSubject.setText("");
|
||||
textAreaContent.setText("");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
showError(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void setSenderEmail(String username) {
|
||||
txtFrom.setText(username);
|
||||
}
|
||||
|
||||
public void getFassade(EasyMail fassade) {
|
||||
this.fassade = fassade;
|
||||
}
|
||||
|
||||
public void showWindow() {
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
public void closeWindow() {
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
public void showInfo(String info) {
|
||||
JOptionPane.showMessageDialog(this,info,"Success", JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
|
||||
public void showError(String error) {
|
||||
JOptionPane.showMessageDialog(this,error,"Error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,197 +1,131 @@
|
|||
package gui;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
|
||||
import domain.EasyMail;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class EasyMailWindow extends JFrame {
|
||||
public class EasyMailWindow extends TemplateWindow {
|
||||
|
||||
private JTable inboxTable;
|
||||
private DefaultTableModel inboxTableModel;
|
||||
private EasyMail fassade;
|
||||
private JLabel fullName,username;
|
||||
private DefaultTableModel inboxTableModel;
|
||||
|
||||
public EasyMailWindow() {
|
||||
setResizable(false);
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
setBounds(100, 100, 1143, 774);
|
||||
setLocationRelativeTo(null);
|
||||
public EasyMailWindow() {
|
||||
super("EasyMail");
|
||||
initUI();
|
||||
}
|
||||
|
||||
JPanel contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
|
||||
// Profile Panel
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBackground(new Color(230, 230, 230));
|
||||
panel.setBorder(new LineBorder(new Color(0, 0, 0), 2));
|
||||
panel.setBounds(10, 273, 347, 451);
|
||||
contentPane.add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel sentEmails = new JLabel("Sent");
|
||||
sentEmails.setForeground(new Color(0, 0, 255));
|
||||
sentEmails.setFont(new Font("Times New Roman", Font.PLAIN, 22));
|
||||
sentEmails.setBounds(10, 11, 165, 39);
|
||||
panel.add(sentEmails);
|
||||
|
||||
sentEmails.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||
sentEmails.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
SentWindow sentWindow = new SentWindow();
|
||||
closeWindow();
|
||||
sentWindow.showWindow();
|
||||
sentWindow.getFassade(fassade);
|
||||
sentWindow.getAllSentEmails();
|
||||
showUserDetails();
|
||||
}
|
||||
});
|
||||
|
||||
JLabel trash = new JLabel("Trash");
|
||||
trash.setForeground(new Color(0, 0, 255));
|
||||
trash.setFont(new Font("Times New Roman", Font.PLAIN, 22));
|
||||
trash.setBounds(10, 61, 165, 39);
|
||||
panel.add(trash);
|
||||
trash.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||
trash.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
TrashWindow trash = new TrashWindow();
|
||||
closeWindow();
|
||||
trash.showWindow();
|
||||
trash.getFassade(fassade);
|
||||
trash.getAllTrashEmails();
|
||||
showUserDetails();
|
||||
}
|
||||
});
|
||||
private void initUI() {
|
||||
initNavigationPanel();
|
||||
initComposePanel();
|
||||
initTablePanel();
|
||||
getAllInboxEmails();
|
||||
showUserDetails();
|
||||
}
|
||||
|
||||
|
||||
JPanel panel_1 = new JPanel();
|
||||
panel_1.setBackground(new Color(230, 230, 230));
|
||||
panel_1.setBorder(new LineBorder(new Color(0, 0, 0), 2));
|
||||
panel_1.setBounds(10, 11, 347, 239);
|
||||
contentPane.add(panel_1);
|
||||
panel_1.setLayout(null);
|
||||
|
||||
JLabel profile = new JLabel("Profile");
|
||||
profile.setFont(new Font("Times New Roman", Font.BOLD, 30));
|
||||
profile.setBounds(10, 11, 203, 41);
|
||||
panel_1.add(profile);
|
||||
private void initNavigationPanel() {
|
||||
JPanel navigationPanel = createPanel(10, 273, 347, 451, new Color(230, 230, 230), true);
|
||||
contentPane.add(navigationPanel);
|
||||
navigationPanel.setLayout(null);
|
||||
|
||||
fullName = new JLabel("Full Name: ");
|
||||
fullName.setFont(new Font("Times New Roman", Font.PLAIN, 20));
|
||||
fullName.setBounds(10, 63, 327, 41);
|
||||
panel_1.add(fullName);
|
||||
JLabel sentEmails = createLabel("Sent", 10, 11, 165, 39, 22);
|
||||
sentEmails.setForeground(Color.BLUE);
|
||||
sentEmails.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||
sentEmails.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
handleSentClick();
|
||||
}
|
||||
});
|
||||
navigationPanel.add(sentEmails);
|
||||
|
||||
username = new JLabel("Email: ");
|
||||
username.setFont(new Font("Times New Roman", Font.PLAIN, 20));
|
||||
username.setBounds(10, 106, 327, 39);
|
||||
panel_1.add(username);
|
||||
JLabel trash = createLabel("Trash", 10, 61, 165, 39, 22);
|
||||
trash.setForeground(Color.BLUE);
|
||||
trash.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||
trash.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
handleTrashClick();
|
||||
}
|
||||
});
|
||||
navigationPanel.add(trash);
|
||||
}
|
||||
|
||||
JLabel editProfile = new JLabel("Edit profile");
|
||||
editProfile.setForeground(Color.BLUE);
|
||||
editProfile.setFont(new Font("Times New Roman", Font.PLAIN, 22));
|
||||
editProfile.setBounds(10, 189, 165, 39);
|
||||
panel_1.add(editProfile);
|
||||
private void initComposePanel() {
|
||||
JPanel composePanel = createPanel(367, 11, 750, 86, new Color(230, 230, 230), true);
|
||||
contentPane.add(composePanel);
|
||||
composePanel.setLayout(null);
|
||||
|
||||
JPanel panel_2 = new JPanel();
|
||||
panel_2.setBorder(new LineBorder(new Color(0, 0, 0), 2));
|
||||
panel_2.setBackground(new Color(230, 230, 230));
|
||||
panel_2.setBounds(367, 11, 750, 86);
|
||||
contentPane.add(panel_2);
|
||||
panel_2.setLayout(null);
|
||||
JLabel writeEmail = createLabel("New Email", 10, 11, 121, 64, 22);
|
||||
writeEmail.setForeground(Color.BLUE);
|
||||
writeEmail.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||
writeEmail.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
handleComposeEmail();
|
||||
}
|
||||
});
|
||||
composePanel.add(writeEmail);
|
||||
}
|
||||
|
||||
JLabel writeEmail = new JLabel("New Email");
|
||||
writeEmail.setForeground(Color.BLUE);
|
||||
writeEmail.setFont(new Font("Times New Roman", Font.PLAIN, 22));
|
||||
writeEmail.setBounds(10, 11, 121, 64);
|
||||
panel_2.add(writeEmail);
|
||||
private void initTablePanel() {
|
||||
JPanel tablePanel = createPanel(367, 105, 750, 619, null, true);
|
||||
contentPane.add(tablePanel);
|
||||
tablePanel.setLayout(null);
|
||||
|
||||
writeEmail.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||
writeEmail.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
handleComposeEmail();
|
||||
}
|
||||
});
|
||||
JScrollPane scrollPane = createTable("From");
|
||||
inboxTableModel = (DefaultTableModel) inboxTable.getModel();
|
||||
scrollPane.setBounds(0, 0, 750, 619);
|
||||
tablePanel.add(scrollPane);
|
||||
}
|
||||
|
||||
JPanel panel_3 = new JPanel();
|
||||
panel_3.setBorder(new LineBorder(new Color(0, 0, 0)));
|
||||
panel_3.setBounds(367, 105, 750, 619);
|
||||
contentPane.add(panel_3);
|
||||
private void handleSentClick() {
|
||||
SentWindow sentWindow = new SentWindow();
|
||||
closeWindow();
|
||||
sentWindow.showWindow();
|
||||
sentWindow.getAllSentEmails();
|
||||
showUserDetails();
|
||||
}
|
||||
|
||||
String[] columnNames = { "From", "Subject", "Date" };
|
||||
inboxTableModel = new DefaultTableModel(columnNames, 0);
|
||||
private void handleTrashClick() {
|
||||
TrashWindow trashWindow = new TrashWindow();
|
||||
closeWindow();
|
||||
trashWindow.showWindow();
|
||||
trashWindow.getAllTrashEmails();
|
||||
showUserDetails();
|
||||
}
|
||||
|
||||
inboxTable = new JTable(inboxTableModel);
|
||||
inboxTable.setFont(new Font("Times New Roman", Font.PLAIN, 16));
|
||||
inboxTable.setRowHeight(24);
|
||||
inboxTable.setDefaultEditor(Object.class, null);
|
||||
panel_3.setLayout(null);
|
||||
public void handleComposeEmail() {
|
||||
ComposeEmailWindow emailWindow = new ComposeEmailWindow();
|
||||
emailWindow.showWindow();
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane(inboxTable);
|
||||
scrollPane.setBounds(0, 0, 750, 619);
|
||||
panel_3.add(scrollPane);
|
||||
}
|
||||
String senderEmail = fassade.getUsernameFromCurrentUser();
|
||||
emailWindow.setSenderEmail(senderEmail);
|
||||
|
||||
public void handleComposeEmail() {
|
||||
ComposeEmailWindow emailWindow = new ComposeEmailWindow();
|
||||
emailWindow.showWindow();
|
||||
emailWindow.getFassade(fassade);
|
||||
emailWindow.setEmailSentListener(() -> {
|
||||
inboxTableModel.setRowCount(0);
|
||||
getAllInboxEmails();
|
||||
});
|
||||
}
|
||||
|
||||
String senderEmail = fassade.getUsernameFromCurrentUser();
|
||||
emailWindow.setSenderEmail(senderEmail);
|
||||
|
||||
emailWindow.setEmailSentListener(() -> {
|
||||
inboxTableModel.setRowCount(0);
|
||||
System.out.println("Jpi");
|
||||
getAllInboxEmails();
|
||||
});
|
||||
}
|
||||
public void getAllInboxEmails() {
|
||||
if (fassade.getUsernameFromCurrentUser() == null) {
|
||||
showError("No user is currently logged in!");
|
||||
return;
|
||||
}
|
||||
inboxTableModel.setRowCount(0);
|
||||
ArrayList<String> getEmails = fassade.sendAllEmailsToInboxWindow();
|
||||
String[] splitEmail;
|
||||
if (getEmails.size() > 0)
|
||||
for (String tempEmail :getEmails ) {
|
||||
splitEmail = tempEmail.split(",");
|
||||
String from = splitEmail[0].toString();
|
||||
String subject = splitEmail[1];
|
||||
String date = splitEmail[2];
|
||||
Object[] newEmail = {from, subject, date};
|
||||
if (getEmails != null && !getEmails.isEmpty())
|
||||
for (String tempEmail : getEmails) {
|
||||
String[] splitEmail = tempEmail.split(",");
|
||||
Object[] newEmail = { splitEmail[0], splitEmail[1], splitEmail[2] };
|
||||
inboxTableModel.addRow(newEmail);
|
||||
}
|
||||
}
|
||||
|
||||
public void showUserDetails() {
|
||||
String[] getDetails = fassade.sendUserDetails();
|
||||
String fullName = getDetails[0];
|
||||
String username = getDetails[1];
|
||||
|
||||
this.fullName.setText(this.fullName.getText() + fullName);
|
||||
this.username.setText(this.username.getText() + username);
|
||||
}
|
||||
|
||||
public void getFassade(EasyMail fassade) {
|
||||
this.fassade = fassade;
|
||||
}
|
||||
|
||||
public void showWindow() {
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
public void closeWindow() {
|
||||
this.dispose();
|
||||
}
|
||||
public void showError(String error) {
|
||||
JOptionPane.showMessageDialog(this, "Error", error, JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,118 +1,70 @@
|
|||
package gui;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.Color;
|
||||
import javax.swing.border.LineBorder;
|
||||
public class LoginWindow extends TemplateWindow {
|
||||
|
||||
import domain.EasyMail;
|
||||
private JTextField txtUsername;
|
||||
private JPasswordField password;
|
||||
private LoginListener loginListener;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import java.awt.Font;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.JPasswordField;
|
||||
import javax.swing.JButton;
|
||||
|
||||
public class LoginWindow extends JFrame {
|
||||
private JTextField txtUsername;
|
||||
private JPasswordField password;
|
||||
private EasyMail fassade;
|
||||
private JPanel panel;
|
||||
private LoginListener loginListener;
|
||||
|
||||
public LoginWindow() {
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
public LoginWindow() {
|
||||
super("Login - EasyMail");
|
||||
setBounds(100, 100, 614, 541);
|
||||
setLocationRelativeTo(null);
|
||||
initUI();
|
||||
}
|
||||
|
||||
JPanel contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
private void initUI() {
|
||||
// Main Panel
|
||||
JPanel panel = createPanel(28, 25, 517, 450, new Color(230, 230, 230), true);
|
||||
contentPane.add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
JLabel logIn = createLabel("Log in", 218, 11, 200, 57, 30);
|
||||
panel.add(logIn);
|
||||
|
||||
panel = new JPanel();
|
||||
panel.setBorder(new LineBorder(new Color(0, 0, 0)));
|
||||
panel.setBackground(new Color(230, 230, 230));
|
||||
panel.setBounds(28, 25, 517, 450);
|
||||
contentPane.add(panel);
|
||||
panel.setLayout(null);
|
||||
JLabel usernameLabel = createLabel("Username:", 10, 92, 120, 46, 25);
|
||||
panel.add(usernameLabel);
|
||||
|
||||
JLabel logIn = new JLabel("Log in");
|
||||
logIn.setFont(new Font("Times New Roman", Font.BOLD, 30));
|
||||
logIn.setBounds(218, 11, 88, 57);
|
||||
panel.add(logIn);
|
||||
txtUsername = createTextField(134, 92, 339, 46);
|
||||
panel.add(txtUsername);
|
||||
|
||||
JLabel username = new JLabel("Username:");
|
||||
username.setFont(new Font("Times New Roman", Font.PLAIN, 25));
|
||||
username.setBounds(10, 92, 120, 46);
|
||||
panel.add(username);
|
||||
JLabel passwordLabel = createLabel("Password:", 10, 180, 120, 46, 25);
|
||||
panel.add(passwordLabel);
|
||||
|
||||
txtUsername = new JTextField();
|
||||
txtUsername.setFont(new Font("Times New Roman", Font.PLAIN, 25));
|
||||
txtUsername.setBounds(134, 92, 339, 46);
|
||||
panel.add(txtUsername);
|
||||
txtUsername.setColumns(10);
|
||||
password = createPasswordField(134, 180, 339, 46);
|
||||
panel.add(password);
|
||||
|
||||
password = new JPasswordField();
|
||||
password.setFont(new Font("Times New Roman", Font.PLAIN, 25));
|
||||
password.setBounds(134, 180, 339, 46);
|
||||
panel.add(password);
|
||||
JButton btnLogIn = createButton("Submit", 10, 270, 120, 35, 16);
|
||||
panel.add(btnLogIn);
|
||||
|
||||
JLabel password = new JLabel("Password:");
|
||||
password.setFont(new Font("Times New Roman", Font.PLAIN, 25));
|
||||
password.setBounds(10, 180, 120, 46);
|
||||
panel.add(password);
|
||||
// Button Action
|
||||
btnLogIn.addActionListener(e -> handleLogin());
|
||||
}
|
||||
|
||||
JButton btnLogIn = new JButton("Submit");
|
||||
btnLogIn.setFont(new Font("Times New Roman", Font.PLAIN, 16));
|
||||
btnLogIn.setBounds(10, 270, 120, 35);
|
||||
panel.add(btnLogIn);
|
||||
btnLogIn.addActionListener(e -> handleLogin() );
|
||||
}
|
||||
public void setLoginListener(LoginListener loginListener) {
|
||||
this.loginListener = loginListener;
|
||||
}
|
||||
|
||||
public boolean handleLogin() {
|
||||
String usernameInput = txtUsername.getText();
|
||||
char[] pass = password.getPassword();
|
||||
|
||||
public void setLoginListener(LoginListener loginListener) {
|
||||
this.loginListener = loginListener;
|
||||
}
|
||||
|
||||
public boolean handleLogin() {
|
||||
String username = txtUsername.getText();
|
||||
char[] pass = password.getPassword();
|
||||
|
||||
boolean loginSuccess = false;
|
||||
try {
|
||||
loginSuccess = fassade.userSignIn(username, pass);
|
||||
} catch (Exception e) {
|
||||
showError(e.getMessage());
|
||||
} finally {
|
||||
java.util.Arrays.fill(pass, ' ');
|
||||
}
|
||||
|
||||
if (loginSuccess && loginListener != null)
|
||||
loginListener.onLoginSuccess();
|
||||
|
||||
return loginSuccess;
|
||||
}
|
||||
|
||||
public void getFassade(EasyMail fassade) {
|
||||
this.fassade = fassade;
|
||||
}
|
||||
public void showWindow() {
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
public void closeWindow() {
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
public void showError(String error) {
|
||||
JOptionPane.showMessageDialog(this, error,"Errore", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
boolean loginSuccess = false;
|
||||
try {
|
||||
loginSuccess = fassade.userSignIn(usernameInput, pass);
|
||||
} catch (Exception e) {
|
||||
showError(e.getMessage());
|
||||
} finally {
|
||||
java.util.Arrays.fill(pass, ' ');
|
||||
}
|
||||
|
||||
if (loginSuccess && loginListener != null) {
|
||||
loginListener.onLoginSuccess();
|
||||
}
|
||||
return loginSuccess;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,66 +1,87 @@
|
|||
package gui;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.border.LineBorder;
|
||||
|
||||
import domain.EasyMail;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class RegisterWindow extends JFrame {
|
||||
public class RegisterWindow extends TemplateWindow {
|
||||
|
||||
private EasyMail fassade;
|
||||
private LoginWindow login;
|
||||
private JTextField firstNameField, lastNameField, usernameField;
|
||||
private LoginWindow login;
|
||||
private JTextField firstNameField, lastNameField, usernameField;
|
||||
private JPasswordField passwordField, confirmPasswordField;
|
||||
private JComboBox<Integer> dayComboBox, yearComboBox;
|
||||
private JComboBox<String> monthComboBox;
|
||||
|
||||
|
||||
public RegisterWindow() {
|
||||
setResizable(false);
|
||||
this.fassade = new EasyMail();
|
||||
|
||||
setTitle("RegisterWindow - EasyMail");
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
super("RegisterWindow - EasyMail");
|
||||
setBounds(100, 100, 754, 893);
|
||||
setLocationRelativeTo(null);
|
||||
setLocationRelativeTo(null);
|
||||
initUI();
|
||||
}
|
||||
|
||||
JPanel contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
contentPane.setLayout(null);
|
||||
private void handleRegister() {
|
||||
try {
|
||||
String firstName = firstNameField.getText();
|
||||
String lastName = lastNameField.getText();
|
||||
String userName = usernameField.getText();
|
||||
char[] password = passwordField.getPassword();
|
||||
char[] passwordConfirmation = confirmPasswordField.getPassword();
|
||||
int day = (int) dayComboBox.getSelectedItem();
|
||||
int year = (int) yearComboBox.getSelectedItem();
|
||||
String month = (String) monthComboBox.getSelectedItem();
|
||||
|
||||
setContentPane(contentPane);
|
||||
fassade.userRegister(firstName, lastName, userName, year, day, month, password, passwordConfirmation);
|
||||
Arrays.fill(password, ' ');
|
||||
Arrays.fill(passwordConfirmation, ' ');
|
||||
restInputs();
|
||||
closeWindow();
|
||||
showEasyMailWindow();
|
||||
} catch (Exception e) {
|
||||
showError(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBackground(new Color(230, 230, 230));
|
||||
panel.setBorder(new LineBorder(new Color(0, 0, 0), 2));
|
||||
panel.setBounds(81, 80, 573, 709);
|
||||
panel.setLayout(null);
|
||||
private void handleLogIn() {
|
||||
login = new LoginWindow();
|
||||
login.showWindow();
|
||||
login.setLoginListener(() -> {
|
||||
login.closeWindow();
|
||||
closeWindow();
|
||||
showEasyMailWindow();
|
||||
});
|
||||
}
|
||||
|
||||
private void showEasyMailWindow() {
|
||||
EasyMailWindow easyMail = new EasyMailWindow();
|
||||
easyMail.showWindow();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void initUI() {
|
||||
JPanel panel = createPanel(81, 80, 573, 709, new Color(230, 230, 230), true);
|
||||
contentPane.add(panel);
|
||||
panel.setLayout(null);
|
||||
|
||||
JLabel titleLabel = new JLabel("RegisterWindow - EasyMail");
|
||||
titleLabel.setFont(new Font("Times New Roman", Font.BOLD, 30));
|
||||
titleLabel.setBounds(85, 11, 387, 53);
|
||||
JLabel titleLabel = createLabel("Register - EasyMail", 85, 11, 387, 53, 30);
|
||||
panel.add(titleLabel);
|
||||
|
||||
// First Name
|
||||
panel.add(createLabel("First Name:", 10, 87));
|
||||
firstNameField = createTextField(284, 96);
|
||||
panel.add(createLabel("First Name:", 10, 87, 200, 30, 25));
|
||||
firstNameField = createTextField(284, 96, 239, 29);
|
||||
panel.add(firstNameField);
|
||||
|
||||
// Last Name
|
||||
panel.add(createLabel("Last Name:", 10, 150));
|
||||
lastNameField = createTextField(284, 150);
|
||||
panel.add(createLabel("Last Name:", 10, 150, 200, 30, 25));
|
||||
lastNameField = createTextField(284, 150, 239, 29);
|
||||
panel.add(lastNameField);
|
||||
|
||||
// Birthdate
|
||||
panel.add(createLabel("Birthdate:", 10, 229));
|
||||
panel.add(createLabel("Birthdate:", 10, 229, 200, 30, 25));
|
||||
|
||||
Integer[] days = IntStream.rangeClosed(1, 31).boxed().toArray(Integer[]::new);
|
||||
dayComboBox = new JComboBox<>(days);
|
||||
|
@ -68,144 +89,63 @@ public class RegisterWindow extends JFrame {
|
|||
dayComboBox.setBounds(284, 229, 50, 29);
|
||||
panel.add(dayComboBox);
|
||||
|
||||
String[] months = {
|
||||
"Januar", "Februar", "März", "April", "Mai", "Juni",
|
||||
"Juli", "August", "September", "Oktober", "November", "Dezember"
|
||||
};
|
||||
String[] months = { "Januar", "Februar", "März", "April", "Mai", "Juni",
|
||||
"Juli", "August", "September", "Oktober", "November", "Dezember" };
|
||||
monthComboBox = new JComboBox<>(months);
|
||||
monthComboBox.setFont(new Font("Times New Roman", Font.PLAIN, 20));
|
||||
monthComboBox.setBounds(344, 229, 110, 29);
|
||||
panel.add(monthComboBox);
|
||||
|
||||
Integer[] years = IntStream.rangeClosed(1900, java.time.LocalDate.now().getYear())
|
||||
.boxed().toArray(Integer[]::new);
|
||||
Integer[] years = IntStream.rangeClosed(1900, java.time.LocalDate.now().getYear()).boxed().toArray(Integer[]::new);
|
||||
yearComboBox = new JComboBox<>(years);
|
||||
yearComboBox.setFont(new Font("Times New Roman", Font.PLAIN, 20));
|
||||
yearComboBox.setBounds(464, 229, 80, 29);
|
||||
yearComboBox.setSelectedItem(2000); // default year
|
||||
yearComboBox.setSelectedItem(2000);
|
||||
panel.add(yearComboBox);
|
||||
|
||||
// Username
|
||||
panel.add(createLabel("Username:", 10, 317));
|
||||
usernameField = createTextField(284, 323);
|
||||
panel.add(createLabel("Username:", 10, 317, 200, 30, 25));
|
||||
usernameField = createTextField(284, 323, 239, 29);
|
||||
panel.add(usernameField);
|
||||
|
||||
// Password
|
||||
panel.add(createLabel("Password:", 10, 405));
|
||||
passwordField = createPasswordField(284, 411);
|
||||
panel.add(createLabel("Password:", 10, 405, 200, 30, 25));
|
||||
passwordField = createPasswordField(284, 411, 239, 29);
|
||||
panel.add(passwordField);
|
||||
|
||||
// Confirm Password
|
||||
panel.add(createLabel("Confirm Password:", 10, 485));
|
||||
confirmPasswordField = createPasswordField(284, 491);
|
||||
panel.add(createLabel("Confirm Password:", 10, 485, 200, 30, 25));
|
||||
confirmPasswordField = createPasswordField(284, 491, 239, 29);
|
||||
panel.add(confirmPasswordField);
|
||||
|
||||
// RegisterWindow Button
|
||||
JButton registerButton = new JButton("Register");
|
||||
registerButton.setFont(new Font("Tahoma", Font.PLAIN, 18));
|
||||
registerButton.setBounds(10, 565, 159, 43);
|
||||
// Register Button
|
||||
JButton registerButton = createButton("Register", 10, 565, 159, 43, 18);
|
||||
panel.add(registerButton);
|
||||
registerButton.addActionListener(e -> handleRegister());
|
||||
|
||||
// Link to Login
|
||||
JLabel loginLabel = new JLabel("Login");
|
||||
JLabel loginLabel = createLabel("Login", 406, 566, 117, 29, 25);
|
||||
loginLabel.setForeground(new Color(0, 0, 160));
|
||||
loginLabel.setFont(new Font("Times New Roman", Font.BOLD, 25));
|
||||
loginLabel.setBounds(406, 566, 117, 29);
|
||||
panel.add(loginLabel);
|
||||
loginLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||
panel.add(loginLabel);
|
||||
loginLabel.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
handleLogIn();
|
||||
handleLogIn();
|
||||
}
|
||||
});
|
||||
|
||||
showWindow();
|
||||
}
|
||||
|
||||
private JLabel createLabel(String text, int x, int y) {
|
||||
JLabel label = new JLabel(text);
|
||||
label.setFont(new Font("Times New Roman", Font.PLAIN, 25));
|
||||
label.setBounds(x, y, 200, 30);
|
||||
return label;
|
||||
|
||||
|
||||
private void restInputs() {
|
||||
this.firstNameField.setText("");
|
||||
this.lastNameField.setText("");
|
||||
this.usernameField.setText("");
|
||||
this.passwordField.setText("");
|
||||
this.confirmPasswordField.setText("");
|
||||
}
|
||||
|
||||
private JTextField createTextField(int x, int y) {
|
||||
JTextField textField = new JTextField();
|
||||
textField.setFont(new Font("Times New Roman", Font.PLAIN, 20));
|
||||
textField.setBounds(x, y, 239, 29);
|
||||
return textField;
|
||||
}
|
||||
|
||||
private JPasswordField createPasswordField(int x, int y) {
|
||||
JPasswordField passwordField = new JPasswordField();
|
||||
passwordField.setFont(new Font("Times New Roman", Font.PLAIN, 20));
|
||||
passwordField.setBounds(x, y, 239, 29);
|
||||
return passwordField;
|
||||
}
|
||||
|
||||
private void handleRegister() {
|
||||
try {
|
||||
String firstName = firstNameField.getText();
|
||||
String lastName = lastNameField.getText();
|
||||
String userName = usernameField.getText();
|
||||
char[] password = passwordField.getPassword();
|
||||
char[] passwordConfirmation = confirmPasswordField.getPassword();
|
||||
int day = (int) dayComboBox.getSelectedItem();
|
||||
int year = (int) yearComboBox.getSelectedItem();
|
||||
String month = (String) monthComboBox.getSelectedItem();
|
||||
|
||||
|
||||
fassade.userRegister(firstName, lastName, userName, year, day, month, password, passwordConfirmation);
|
||||
Arrays.fill(password, ' ');
|
||||
Arrays.fill(passwordConfirmation, ' ');
|
||||
restInputs();
|
||||
this.closeWindow();
|
||||
showEasyMailWindow();
|
||||
|
||||
} catch (Exception e) {
|
||||
showError(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void handleLogIn() {
|
||||
login = new LoginWindow();
|
||||
login.showWindow();
|
||||
login.getFassade(fassade);
|
||||
|
||||
login.setLoginListener(() -> {
|
||||
|
||||
login.dispose();
|
||||
closeWindow();
|
||||
showEasyMailWindow();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void showEasyMailWindow() {
|
||||
EasyMailWindow easyMail = new EasyMailWindow();
|
||||
easyMail.showWindow();
|
||||
easyMail.getFassade(fassade);
|
||||
easyMail.showUserDetails();
|
||||
}
|
||||
|
||||
|
||||
public void showWindow() {
|
||||
this.setVisible(true);
|
||||
}
|
||||
public void closeWindow() {
|
||||
this.dispose();
|
||||
}
|
||||
public void showError(String error) {
|
||||
JOptionPane.showMessageDialog(this, error, "Error" , JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
public void restInputs() {
|
||||
this.firstNameField.setText("");
|
||||
this.lastNameField.setText("");
|
||||
this.usernameField.setText("");
|
||||
this.passwordField.setText("");
|
||||
this.passwordField.setText("");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,174 +1,92 @@
|
|||
package gui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Font;
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.border.LineBorder;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
public class SentWindow extends TemplateWindow {
|
||||
|
||||
import domain.EasyMail;
|
||||
private DefaultTableModel inboxTableModel;
|
||||
|
||||
public class SentWindow extends JFrame {
|
||||
public SentWindow() {
|
||||
super("Sent - EasyMail");
|
||||
initUI();
|
||||
}
|
||||
|
||||
private JTable inboxTable;
|
||||
private DefaultTableModel inboxTableModel;
|
||||
private EasyMail fassade;
|
||||
private JLabel fullName,username;
|
||||
private void initUI() {
|
||||
initNavigationPanel();
|
||||
initTablePanel();
|
||||
initComposePanel();
|
||||
showUserDetails();
|
||||
}
|
||||
|
||||
public SentWindow() {
|
||||
setResizable(false);
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
setBounds(100, 100, 1143, 774);
|
||||
setLocationRelativeTo(null);
|
||||
private void initComposePanel() {
|
||||
JPanel composePanel = createPanel(367, 11, 750, 86, new Color(230, 230, 230), true);
|
||||
contentPane.add(composePanel);
|
||||
composePanel.setLayout(null);
|
||||
|
||||
JPanel contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
}
|
||||
|
||||
// Profile Panel
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBackground(new Color(230, 230, 230));
|
||||
panel.setBorder(new LineBorder(new Color(0, 0, 0), 2));
|
||||
panel.setBounds(10, 273, 347, 451);
|
||||
contentPane.add(panel);
|
||||
panel.setLayout(null);
|
||||
private void initNavigationPanel() {
|
||||
JPanel navigationPanel = createPanel(10, 273, 347, 451, new Color(230, 230, 230), true);
|
||||
contentPane.add(navigationPanel);
|
||||
navigationPanel.setLayout(null);
|
||||
|
||||
JLabel inbox = new JLabel("Inbox");
|
||||
inbox.setForeground(new Color(0, 0, 255));
|
||||
inbox.setFont(new Font("Times New Roman", Font.PLAIN, 22));
|
||||
inbox.setBounds(10, 11, 165, 39);
|
||||
panel.add(inbox);
|
||||
inbox.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||
inbox.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
EasyMailWindow easyMail = new EasyMailWindow();
|
||||
closeWindow();
|
||||
easyMail.showWindow();
|
||||
easyMail.getFassade(fassade);
|
||||
easyMail.getAllInboxEmails();
|
||||
JLabel inbox = createLabel("Inbox", 10, 11, 165, 39, 22);
|
||||
inbox.setForeground(Color.BLUE);
|
||||
inbox.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||
inbox.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
EasyMailWindow easyMailWindow = new EasyMailWindow();
|
||||
closeWindow();
|
||||
easyMailWindow.showWindow();
|
||||
easyMailWindow.getAllInboxEmails();
|
||||
}
|
||||
});
|
||||
navigationPanel.add(inbox);
|
||||
|
||||
}
|
||||
});
|
||||
JLabel trash = new JLabel("Trash");
|
||||
trash.setForeground(new Color(0, 0, 255));
|
||||
trash.setFont(new Font("Times New Roman", Font.PLAIN, 22));
|
||||
trash.setBounds(10, 61, 165, 39);
|
||||
panel.add(trash);
|
||||
trash.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||
trash.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
TrashWindow trash = new TrashWindow();
|
||||
closeWindow();
|
||||
trash.showWindow();
|
||||
trash.getFassade(fassade);
|
||||
trash.getAllTrashEmails();
|
||||
}
|
||||
});
|
||||
JLabel trash = createLabel("Trash", 10, 61, 165, 39, 22);
|
||||
trash.setForeground(Color.BLUE);
|
||||
trash.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||
trash.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
TrashWindow trashWindow = new TrashWindow();
|
||||
closeWindow();
|
||||
trashWindow.showWindow();
|
||||
trashWindow.getAllTrashEmails();
|
||||
}
|
||||
});
|
||||
navigationPanel.add(trash);
|
||||
}
|
||||
|
||||
JPanel panel_1 = new JPanel();
|
||||
panel_1.setBackground(new Color(230, 230, 230));
|
||||
panel_1.setBorder(new LineBorder(new Color(0, 0, 0), 2));
|
||||
panel_1.setBounds(10, 11, 347, 239);
|
||||
contentPane.add(panel_1);
|
||||
panel_1.setLayout(null);
|
||||
private void initTablePanel() {
|
||||
JPanel tablePanel = createPanel(367, 105, 750, 619, null, true);
|
||||
contentPane.add(tablePanel);
|
||||
tablePanel.setLayout(null);
|
||||
|
||||
JLabel profile = new JLabel("Profile");
|
||||
profile.setFont(new Font("Times New Roman", Font.BOLD, 30));
|
||||
profile.setBounds(10, 11, 203, 41);
|
||||
panel_1.add(profile);
|
||||
|
||||
fullName = new JLabel("Full Name: ");
|
||||
fullName.setFont(new Font("Times New Roman", Font.PLAIN, 20));
|
||||
fullName.setBounds(10, 63, 327, 41);
|
||||
panel_1.add(fullName);
|
||||
|
||||
username = new JLabel("Email: ");
|
||||
username.setFont(new Font("Times New Roman", Font.PLAIN, 20));
|
||||
username.setBounds(10, 106, 327, 39);
|
||||
panel_1.add(username);
|
||||
|
||||
JLabel editProfile = new JLabel("Edit profile");
|
||||
editProfile.setForeground(Color.BLUE);
|
||||
editProfile.setFont(new Font("Times New Roman", Font.PLAIN, 22));
|
||||
editProfile.setBounds(10, 189, 165, 39);
|
||||
panel_1.add(editProfile);
|
||||
|
||||
JPanel panel_2 = new JPanel();
|
||||
panel_2.setBorder(new LineBorder(new Color(0, 0, 0), 2));
|
||||
panel_2.setBackground(new Color(230, 230, 230));
|
||||
panel_2.setBounds(367, 11, 750, 86);
|
||||
contentPane.add(panel_2);
|
||||
panel_2.setLayout(null);
|
||||
|
||||
JPanel panel_3 = new JPanel();
|
||||
panel_3.setBorder(new LineBorder(new Color(0, 0, 0)));
|
||||
panel_3.setBounds(367, 105, 750, 619);
|
||||
contentPane.add(panel_3);
|
||||
|
||||
String[] columnNames = { "An", "Subject", "Date" };
|
||||
inboxTableModel = new DefaultTableModel(columnNames, 0);
|
||||
|
||||
inboxTable = new JTable(inboxTableModel);
|
||||
inboxTable.setFont(new Font("Times New Roman", Font.PLAIN, 16));
|
||||
inboxTable.setRowHeight(24);
|
||||
inboxTable.setDefaultEditor(Object.class, null);
|
||||
panel_3.setLayout(null);
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane(inboxTable);
|
||||
scrollPane.setBounds(0, 0, 750, 619);
|
||||
panel_3.add(scrollPane);
|
||||
}
|
||||
|
||||
public void showUserDetails() {
|
||||
String[] getDetails = fassade.sendUserDetails();
|
||||
String fullName = getDetails[0];
|
||||
String username = getDetails[1];
|
||||
|
||||
this.fullName.setText(this.fullName.getText() + fullName);
|
||||
this.username.setText(this.username.getText() + username);
|
||||
}
|
||||
JScrollPane scrollPane = createTable("To");
|
||||
inboxTableModel = (DefaultTableModel) inboxTable.getModel();
|
||||
scrollPane.setBounds(0, 0, 750, 619);
|
||||
tablePanel.add(scrollPane);
|
||||
}
|
||||
|
||||
public void getAllSentEmails() {
|
||||
ArrayList<String> getEmails = fassade.sendAllEmailsToSentWindow();
|
||||
ArrayList<String> getEmails = fassade.sendAllEmailstoSentWindow();
|
||||
String[] splitEmail;
|
||||
if (getEmails.size() > 0)
|
||||
for (String tempEmail :getEmails ) {
|
||||
for (String tempEmail : getEmails) {
|
||||
splitEmail = tempEmail.split(",");
|
||||
String to = splitEmail[0].toString();
|
||||
String subject = splitEmail[1];
|
||||
String date = splitEmail[2];
|
||||
Object[] newEmail = {to, subject, date};
|
||||
Object[] newEmail = { to, subject, date };
|
||||
inboxTableModel.addRow(newEmail);
|
||||
}
|
||||
}
|
||||
|
||||
public void getFassade(EasyMail fassade) {
|
||||
this.fassade = fassade;
|
||||
}
|
||||
|
||||
public void showWindow() {
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
public void closeWindow() {
|
||||
this.dispose();
|
||||
}
|
||||
public void showError(String error) {
|
||||
JOptionPane.showMessageDialog(this, "Error", error, JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,141 @@
|
|||
package gui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Font;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.border.LineBorder;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
|
||||
import domain.EasyMail;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.*;
|
||||
|
||||
public abstract class TemplateWindow extends JFrame {
|
||||
|
||||
protected JPanel contentPane;
|
||||
protected static EasyMail fassade = new EasyMail();
|
||||
protected JLabel fullName, username, editProfile;
|
||||
protected JTable inboxTable;
|
||||
|
||||
public TemplateWindow(String title) {
|
||||
setTitle(title);
|
||||
setResizable(false);
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
setBounds(100, 100, 1143, 774);
|
||||
setLocationRelativeTo(null);
|
||||
initContentPane();
|
||||
}
|
||||
|
||||
private void initContentPane() {
|
||||
contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
contentPane.setLayout(null);
|
||||
setContentPane(contentPane);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void showUserDetails() {
|
||||
JPanel profilePanel = createPanel(10, 11, 347, 239, new Color(230, 230, 230), true);
|
||||
contentPane.add(profilePanel);
|
||||
profilePanel.setLayout(null);
|
||||
JLabel profile = createLabel("Profile", 10, 11, 203, 41, 30);
|
||||
profilePanel.add(profile);
|
||||
editProfile = createLabel("Edit profile", 10, 189, 165, 39, 22);
|
||||
editProfile.setForeground(Color.BLUE);
|
||||
profilePanel.add(editProfile);
|
||||
|
||||
String[] getDetails = fassade.sendUserDetails();
|
||||
String fullName = getDetails[0];
|
||||
String username = getDetails[1];
|
||||
this.fullName = createLabel("",10,63, 327, 41,20);
|
||||
this.username = createLabel("",10, 106, 327, 39,20);
|
||||
this.fullName.setText("Full Name: " + fullName);
|
||||
this.username.setText("Email: " + username);
|
||||
profilePanel.add(this.fullName);
|
||||
profilePanel.add(this.username);
|
||||
}
|
||||
|
||||
// Neue Methode
|
||||
protected JPanel createPanel(int x, int y, int width, int height, Color bgColor, boolean withBorder) {
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBounds(x, y, width, height);
|
||||
panel.setBackground(bgColor != null ? bgColor : new Color(230, 230, 230));
|
||||
panel.setLayout(null);
|
||||
if (withBorder) {
|
||||
panel.setBorder(new LineBorder(Color.BLACK, 2));
|
||||
}
|
||||
return panel;
|
||||
}
|
||||
|
||||
protected JScrollPane createTable(String from_To) {
|
||||
String[] columnNames = { from_To, "Subject", "Date" };
|
||||
DefaultTableModel inboxTableModel = new DefaultTableModel(columnNames, 0);
|
||||
inboxTable = new JTable(inboxTableModel);
|
||||
inboxTable.setFont(new Font("Times New Roman", Font.PLAIN, 16));
|
||||
inboxTable.setRowHeight(24);
|
||||
inboxTable.setDefaultEditor(Object.class, null);
|
||||
JScrollPane scrollPane = new JScrollPane(inboxTable);
|
||||
scrollPane.setBounds(0, 0, 750, 619);
|
||||
return scrollPane;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected JLabel createLabel(String text, int x, int y, int width, int height, int fontSize) {
|
||||
JLabel label = new JLabel(text);
|
||||
label.setFont(new Font("Times New Roman", Font.PLAIN, fontSize));
|
||||
label.setBounds(x, y, width, height);
|
||||
return label;
|
||||
}
|
||||
|
||||
protected JButton createButton(String text, int x, int y, int width, int height, int fontSize) {
|
||||
JButton button = new JButton(text);
|
||||
button.setFont(new Font("Times New Roman", Font.PLAIN, fontSize));
|
||||
button.setBounds(x, y, width, height);
|
||||
return button;
|
||||
}
|
||||
|
||||
protected JTextField createTextField(int x, int y, int width, int height) {
|
||||
JTextField textField = new JTextField();
|
||||
textField.setFont(new Font("Times New Roman", Font.PLAIN, 20));
|
||||
textField.setBounds(x, y, width, height);
|
||||
return textField;
|
||||
}
|
||||
|
||||
protected JPasswordField createPasswordField(int x, int y, int width, int height) {
|
||||
JPasswordField passwordField = new JPasswordField();
|
||||
passwordField.setFont(new Font("Times New Roman", Font.PLAIN, 20));
|
||||
passwordField.setBounds(x, y, width, height);
|
||||
return passwordField;
|
||||
}
|
||||
|
||||
protected void showWindow() {
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
protected void closeWindow() {
|
||||
this.dispose();
|
||||
}
|
||||
|
||||
protected void showError(String error) {
|
||||
JOptionPane.showMessageDialog(this, error, "Error", JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
protected void showInfo(String info) {
|
||||
JOptionPane.showMessageDialog(this, info, "Information", JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
}
|
|
@ -1,178 +1,86 @@
|
|||
package gui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Font;
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.border.LineBorder;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
public class TrashWindow extends TemplateWindow {
|
||||
|
||||
import domain.EasyMail;
|
||||
private DefaultTableModel inboxTableModel;
|
||||
|
||||
public class TrashWindow extends JFrame {
|
||||
public TrashWindow() {
|
||||
super("Trash - EasyMail");
|
||||
initUI();
|
||||
}
|
||||
|
||||
private void initUI() {
|
||||
initNavigationPanel();
|
||||
initTablePanel();
|
||||
initComposePanel();
|
||||
showUserDetails();
|
||||
}
|
||||
|
||||
private JTable inboxTable;
|
||||
private DefaultTableModel inboxTableModel;
|
||||
private EasyMail fassade;
|
||||
private JLabel fullName,username;
|
||||
private void initComposePanel() {
|
||||
JPanel composePanel = createPanel(367, 11, 750, 86, new Color(230, 230, 230), true);
|
||||
contentPane.add(composePanel);
|
||||
composePanel.setLayout(null);
|
||||
|
||||
public TrashWindow() {
|
||||
setResizable(false);
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
setBounds(100, 100, 1143, 774);
|
||||
setLocationRelativeTo(null);
|
||||
}
|
||||
|
||||
JPanel contentPane = new JPanel();
|
||||
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
setContentPane(contentPane);
|
||||
contentPane.setLayout(null);
|
||||
private void initNavigationPanel() {
|
||||
JPanel navigationPanel = createPanel(10, 273, 347, 451, new Color(230, 230, 230), true);
|
||||
contentPane.add(navigationPanel);
|
||||
navigationPanel.setLayout(null);
|
||||
|
||||
// Profile Panel
|
||||
JPanel panel = new JPanel();
|
||||
panel.setBackground(new Color(230, 230, 230));
|
||||
panel.setBorder(new LineBorder(new Color(0, 0, 0), 2));
|
||||
panel.setBounds(10, 273, 347, 451);
|
||||
contentPane.add(panel);
|
||||
panel.setLayout(null);
|
||||
JLabel inbox = createLabel("Inbox", 10, 11, 165, 39, 22);
|
||||
inbox.setForeground(Color.BLUE);
|
||||
inbox.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||
inbox.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
EasyMailWindow easyMailWindow = new EasyMailWindow();
|
||||
closeWindow();
|
||||
easyMailWindow.showWindow();
|
||||
easyMailWindow.getAllInboxEmails();
|
||||
}
|
||||
});
|
||||
navigationPanel.add(inbox);
|
||||
|
||||
JLabel inbox = new JLabel("Inbox");
|
||||
inbox.setForeground(new Color(0, 0, 255));
|
||||
inbox.setFont(new Font("Times New Roman", Font.PLAIN, 22));
|
||||
inbox.setBounds(10, 11, 165, 39);
|
||||
panel.add(inbox);
|
||||
inbox.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||
inbox.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
EasyMailWindow easyMail = new EasyMailWindow();
|
||||
closeWindow();
|
||||
easyMail.showWindow();
|
||||
easyMail.getFassade(fassade);
|
||||
easyMail.getAllInboxEmails();
|
||||
}
|
||||
});
|
||||
JLabel sentEmails = createLabel("Sent", 10, 61, 165, 39, 22);
|
||||
sentEmails.setForeground(Color.BLUE);
|
||||
sentEmails.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||
sentEmails.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
SentWindow sentWindow = new SentWindow();
|
||||
closeWindow();
|
||||
sentWindow.showWindow();
|
||||
sentWindow.getAllSentEmails();
|
||||
}
|
||||
});
|
||||
navigationPanel.add(sentEmails);
|
||||
}
|
||||
|
||||
private void initTablePanel() {
|
||||
JPanel tablePanel = createPanel(367, 105, 750, 619, null, true);
|
||||
contentPane.add(tablePanel);
|
||||
tablePanel.setLayout(null);
|
||||
|
||||
JScrollPane scrollPane = createTable("From");
|
||||
inboxTableModel = (DefaultTableModel) inboxTable.getModel();
|
||||
scrollPane.setBounds(0, 0, 750, 619);
|
||||
tablePanel.add(scrollPane);
|
||||
}
|
||||
|
||||
JLabel sentEmails = new JLabel("Sent");
|
||||
sentEmails.setForeground(new Color(0, 0, 255));
|
||||
sentEmails.setFont(new Font("Times New Roman", Font.PLAIN, 22));
|
||||
sentEmails.setBounds(10, 61, 165, 39);
|
||||
panel.add(sentEmails);
|
||||
|
||||
sentEmails.setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||
sentEmails.addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
SentWindow sentWindow = new SentWindow();
|
||||
closeWindow();
|
||||
sentWindow.showWindow();
|
||||
sentWindow.getFassade(fassade);
|
||||
sentWindow.getAllSentEmails();
|
||||
}
|
||||
});
|
||||
|
||||
JPanel panel_1 = new JPanel();
|
||||
panel_1.setBackground(new Color(230, 230, 230));
|
||||
panel_1.setBorder(new LineBorder(new Color(0, 0, 0), 2));
|
||||
panel_1.setBounds(10, 11, 347, 239);
|
||||
contentPane.add(panel_1);
|
||||
panel_1.setLayout(null);
|
||||
|
||||
JLabel profile = new JLabel("Profile");
|
||||
profile.setFont(new Font("Times New Roman", Font.BOLD, 30));
|
||||
profile.setBounds(10, 11, 203, 41);
|
||||
panel_1.add(profile);
|
||||
|
||||
fullName = new JLabel("Full Name: ");
|
||||
fullName.setFont(new Font("Times New Roman", Font.PLAIN, 20));
|
||||
fullName.setBounds(10, 63, 327, 41);
|
||||
panel_1.add(fullName);
|
||||
|
||||
username = new JLabel("Email: ");
|
||||
username.setFont(new Font("Times New Roman", Font.PLAIN, 20));
|
||||
username.setBounds(10, 106, 327, 39);
|
||||
panel_1.add(username);
|
||||
|
||||
JLabel editProfile = new JLabel("Edit profile");
|
||||
editProfile.setForeground(Color.BLUE);
|
||||
editProfile.setFont(new Font("Times New Roman", Font.PLAIN, 22));
|
||||
editProfile.setBounds(10, 189, 165, 39);
|
||||
panel_1.add(editProfile);
|
||||
|
||||
JPanel panel_2 = new JPanel();
|
||||
panel_2.setBorder(new LineBorder(new Color(0, 0, 0), 2));
|
||||
panel_2.setBackground(new Color(230, 230, 230));
|
||||
panel_2.setBounds(367, 11, 750, 86);
|
||||
contentPane.add(panel_2);
|
||||
panel_2.setLayout(null);
|
||||
|
||||
JPanel panel_3 = new JPanel();
|
||||
panel_3.setBorder(new LineBorder(new Color(0, 0, 0)));
|
||||
panel_3.setBounds(367, 105, 750, 619);
|
||||
contentPane.add(panel_3);
|
||||
|
||||
String[] columnNames = { "From", "Subject", "Date" };
|
||||
inboxTableModel = new DefaultTableModel(columnNames, 0);
|
||||
|
||||
inboxTable = new JTable(inboxTableModel);
|
||||
inboxTable.setFont(new Font("Times New Roman", Font.PLAIN, 16));
|
||||
inboxTable.setRowHeight(24);
|
||||
inboxTable.setDefaultEditor(Object.class, null);
|
||||
panel_3.setLayout(null);
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane(inboxTable);
|
||||
scrollPane.setBounds(0, 0, 750, 619);
|
||||
panel_3.add(scrollPane);
|
||||
}
|
||||
|
||||
public void showUserDetails() {
|
||||
String[] getDetails = fassade.sendUserDetails();
|
||||
String fullName = getDetails[0];
|
||||
String username = getDetails[1];
|
||||
|
||||
this.fullName.setText(this.fullName.getText() + fullName);
|
||||
this.username.setText(this.username.getText() + username);
|
||||
}
|
||||
|
||||
public void getAllTrashEmails() {
|
||||
ArrayList<String> getEmails = fassade.sendAllEmailsToTrashWindow();
|
||||
String[] splitEmail;
|
||||
if (getEmails.size() > 0)
|
||||
for (String tempEmail :getEmails ) {
|
||||
splitEmail = tempEmail.split(",");
|
||||
String from = splitEmail[0].toString();
|
||||
String subject = splitEmail[1];
|
||||
String date = splitEmail[2];
|
||||
Object[] newEmail = {from, subject, date};
|
||||
inboxTableModel.addRow(newEmail);
|
||||
}
|
||||
}
|
||||
|
||||
public void getFassade(EasyMail fassade) {
|
||||
this.fassade = fassade;
|
||||
}
|
||||
|
||||
public void showWindow() {
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
public void closeWindow() {
|
||||
this.dispose();
|
||||
}
|
||||
public void showError(String error) {
|
||||
JOptionPane.showMessageDialog(this, "Error", error, JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
public void getAllTrashEmails() {
|
||||
ArrayList<String> getEmails = fassade.sendAllEmailsToTrashWindow();
|
||||
for (String tempEmail : getEmails) {
|
||||
String[] splitEmail = tempEmail.split(",");
|
||||
Object[] newEmail = {splitEmail[0], splitEmail[1], splitEmail[2]};
|
||||
inboxTableModel.addRow(newEmail);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue