-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathViewAddQuestionPreviewDialog.java
68 lines (55 loc) · 1.83 KB
/
ViewAddQuestionPreviewDialog.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
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
public class ViewAddQuestionPreviewDialog extends JDialog {
private JPanel scrollPane;
private Controller controller;
public ViewAddQuestionPreviewDialog(Controller controller) {
this.controller = controller;
setBackground(new Color(240, 255, 255));
setPreferredSize(new Dimension(400, 150));
setLayout(new BorderLayout());
setResizable(false);
scrollPane = new JPanel();
scrollPane.setLayout(new BoxLayout(scrollPane, BoxLayout.Y_AXIS));
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
add(scrollPane, BorderLayout.NORTH);
addWindowListener(controller);
JButton btnNewButton = new JButton("Submit");
btnNewButton.setActionCommand("PreviewSubmit");
btnNewButton.setFont(new Font("Tahoma", Font.BOLD, 11));
btnNewButton.addActionListener(controller);
JButton btnNewButton1 = new JButton("Show Answer");
btnNewButton1.setActionCommand("PreviewShowAnswer");
btnNewButton1.setFont(new Font("Tahoma", Font.BOLD, 11));
btnNewButton1.addActionListener(controller);
JPanel p = new JPanel();
p.add(btnNewButton);
//p.add(btnNewButton1);
add(p, BorderLayout.SOUTH);
pack();
}
public void Update() {
if (controller.getSampleQuestion() != null) {
showedQuestion(controller.getSampleQuestion());
}
else
scrollPane.removeAll();
}
public void showedQuestion(IQuestion question) {
scrollPane.removeAll();
scrollPane.add((Component) question);
}
}