-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTouchTypeRead.java
More file actions
64 lines (62 loc) · 2.33 KB
/
TouchTypeRead.java
File metadata and controls
64 lines (62 loc) · 2.33 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
//Sinan Karabocuoglu
//10 July 2018
//TouchTypeRead
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.*;
public class TouchTypeRead {
//attitutes
static JProgressBar accuracyBar = new JProgressBar();
static FrameComponents components = new FrameComponents();
static JLabel label = new JLabel("The Accuracy of the Answers: %" + components.accuracy);
static JLabel label2 = new JLabel("Words per Minute: " + components.wordPerMin);
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setTitle("Touch-Type-Read");
frame.setSize(650, 400);
//closes on exit
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//sets the position
frame.setLocationRelativeTo(null);
//sets nonresizable
frame.setResizable(false);
JButton next = new JButton("Next Page");
JButton previous = new JButton("Previous Page");
//********ButtonListeners******
class ButtonListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
if (e.getSource() == next) {
components.nextPage();
} else {
components.prevPage();
}
}
}
//********************************
//*****buttons for navigating*******
JPanel panel = new JPanel(new GridLayout(1, 2));
ButtonListener listener = new ButtonListener();
next.addActionListener(listener);
previous.addActionListener(listener);
panel.add(previous);
panel.add(next);
frame.add(panel, BorderLayout.SOUTH);
JTabbedPane tabs = new JTabbedPane();
//**********************************
JPanel statsPanel = new JPanel(new GridLayout(3,1));
statsPanel.add(label);
accuracyBar.setValue((int)components.accuracy);
statsPanel.add(accuracyBar);
statsPanel.add(label2);
//****panel for progress and statistics***
tabs.addTab("Text",components);
tabs.add("Statistics",statsPanel);
frame.add(tabs, BorderLayout.CENTER);
//sets the frame visible
frame.setVisible(true);
}
}