-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHistoryGUI.java
More file actions
57 lines (48 loc) · 1.4 KB
/
Copy pathHistoryGUI.java
File metadata and controls
57 lines (48 loc) · 1.4 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
import java.awt.BorderLayout;
import java.util.Stack;
import javafx.util.Pair;
import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
/**
*
* @author Baqir 4.0.2
*/
public class HistoryGUI extends JFrame {
DefaultListModel<String> model;
JList<String> hist;
Stack<Pair<String, String>> hstack;
JPanel listpan;
public HistoryGUI(Stack<Pair<String, String>> st) {
hstack = st;
initGUI();
}
public void initGUI()
{
setTitle("BROWSER HISTORY");
setListpan();
add(listpan);
setSize(600, 600);
setVisible(true);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}
void setListpan(){
listpan = new JPanel();
Stack<Pair<String, String>> temp = new Stack<Pair<String, String>>();
model = new DefaultListModel<>();
hist = new JList<String>(model);
while (!hstack.empty())
{
model.addElement(hstack.peek().getKey() + " - " + hstack.peek().getValue());
temp.push(hstack.pop());
}
while (!temp.empty())
{
hstack.push(temp.pop());
}
listpan.add(hist, BorderLayout.CENTER);
listpan.add(new JScrollPane(hist));
}
}