-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLandingPageGUI.java
97 lines (85 loc) · 2.7 KB
/
LandingPageGUI.java
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
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
/**
* This class is the first place a user starts when using the Profile Login program.
*
* @author Chandra Adhikari, Jorah Hinman, Phil Gore
*
*/
@SuppressWarnings("serial")
public class LandingPageGUI extends JPanel{
private JPanel mainPanel;
private JButton createProfileButton;
private JLabel whiteSpace;
private JButton loginButton;
private ButtonListener buttonListener;
private AccountManager profile;
public LandingPageGUI() {
initInstanceVars();
initCenterPanel();
}
public LandingPageGUI(AccountManager acct){
this();
setProfile(acct);
}
private void initInstanceVars(){
setLayout(new BorderLayout());
mainPanel = new JPanel();//panel which all of the other panel are added to
mainPanel.setLayout(new BorderLayout());
add(mainPanel);
buttonListener = new ButtonListener();//create button listener
profile = new AccountManager();
}
private void initCenterPanel() {
JPanel centerPanel = new JPanel();//create panel & set the layout
centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.Y_AXIS));
createProfileButton = new JButton("Create Profile!");
loginButton = new JButton("Login");
whiteSpace = new JLabel(" ");
createProfileButton.setFont(new Font(Font.MONOSPACED, Font.BOLD, 20));
loginButton.setFont(new Font(Font.MONOSPACED, Font.BOLD, 20));
createProfileButton.setAlignmentX(Component.CENTER_ALIGNMENT);
loginButton.setAlignmentX(Component.CENTER_ALIGNMENT);
createProfileButton.addActionListener(buttonListener);
loginButton.addActionListener(buttonListener);
centerPanel.add(Box.createVerticalGlue());
centerPanel.add(createProfileButton);
centerPanel.add(whiteSpace);
centerPanel.add(loginButton);
centerPanel.add(Box.createVerticalGlue());
mainPanel.add(centerPanel, BorderLayout.CENTER);
}
private void setProfile(AccountManager acct) {
profile = acct;
}
private class ButtonListener implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource().equals(createProfileButton)){
removeAll();
add(new CreateProfileGUI(profile));
repaint();
revalidate();
setPreferredSize(new Dimension(800, 800));
setVisible(true);
}
if(e.getSource().equals(loginButton)){
removeAll();
add(new LoginGUI(profile));
repaint();
revalidate();
setPreferredSize(new Dimension(800, 800));
setVisible(true);
}
}
}
}