-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFinishScreen.java
executable file
·115 lines (95 loc) · 3.33 KB
/
FinishScreen.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JButton;
import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class FinishScreen {
private JFrame frame;
private JLabel lblUserName;
private JLabel lblLevel;
private JLabel lblXP;
private JLabel lblTotalGuesses;
private JLabel lblCorrectGuesses;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
FinishScreen window = new FinishScreen();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public FinishScreen() {
initialize();
DisplayUsersInformation();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 801, 713);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
lblUserName = new JLabel("User Name here");
lblUserName.setBounds(12, 93, 115, 16);
frame.getContentPane().add(lblUserName);
lblLevel = new JLabel("Their current level");
lblLevel.setBounds(12, 122, 153, 16);
frame.getContentPane().add(lblLevel);
lblXP = new JLabel("Their current Xp");
lblXP.setBounds(12, 151, 99, 16);
frame.getContentPane().add(lblXP);
JLabel lblNameHere = new JLabel("Guessing game ");
lblNameHere.setFont(new Font("Algerian", Font.PLAIN, 30));
lblNameHere.setBounds(286, 13, 300, 66);
frame.getContentPane().add(lblNameHere);
JLabel lblTotalGuessFor = new JLabel("Total Guesses for this image");
lblTotalGuessFor.setBounds(127, 216, 215, 38);
frame.getContentPane().add(lblTotalGuessFor);
JLabel lblNumberOfCorrect = new JLabel("Number of correct guesses");
lblNumberOfCorrect.setBounds(127, 277, 215, 38);
frame.getContentPane().add(lblNumberOfCorrect);
lblTotalGuesses = new JLabel("New label");
lblTotalGuesses.setBounds(460, 227, 56, 16);
frame.getContentPane().add(lblTotalGuesses);
lblCorrectGuesses = new JLabel("New label");
lblCorrectGuesses.setBounds(460, 288, 56, 16);
frame.getContentPane().add(lblCorrectGuesses);
JButton btnReturnHomePage = new JButton("Return to home page");
btnReturnHomePage.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
// Navigate to home page
HomePage homePage = new HomePage();
homePage.Home();
frame.dispose();
}
});
btnReturnHomePage.setBounds(271, 473, 201, 54);
frame.getContentPane().add(btnReturnHomePage);
}
private void DisplayUsersInformation() {
// Variables that will hold user's username, level and xp
String[] userInfor = Client.getNeededInfor("USER_INFO");
// Get information from the database
String[] finalResult = Client.getNeededInfor("FINAL_RESULT", GuessingPage.imageInfo[3]);
// Display user's information
lblUserName.setText("Name: " +userInfor[2]);
lblLevel.setText("Current level: "+userInfor[3]);
lblXP.setText("Current Xp: "+userInfor[4]);
// Display final result
lblTotalGuesses.setText(finalResult[2]);
lblCorrectGuesses.setText(finalResult[1]);
}
}