-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathViewPanel.java
56 lines (47 loc) · 1.37 KB
/
ViewPanel.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
import java.awt.*;
import javax.swing.*;
public class ViewPanel extends JPanel
{
private Discussion discussion = new Discussion();
public ViewPanel() {}
public ViewPanel(Discussion disc)
{
discussion = disc;
setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
initPanel();
}
private void initPanel()
{
if(discussion != null)
{
JTextArea title = new JTextArea("Discussion: "+discussion.getTitle());
title.setFont(new Font("Default", Font.PLAIN, 16));
title.setOpaque(false);
title.setEditable(false);
title.setLineWrap(true);
title.setWrapStyleWord(true);
JPanel titlePanel = new JPanel(new GridLayout(1, 0));
titlePanel.add(title);
titlePanel.setBorder(BorderFactory.createLineBorder(Color.black));
titlePanel.setBorder(BorderFactory.createEmptyBorder(5,2,5,2));
add(titlePanel);
discussion.sortComments();
for(Comment msg : discussion.getAllComments())
{
add(new RemarkPanel(msg));
}
}
Box.Filler glue = (Box.Filler)Box.createVerticalGlue();
glue.changeShape(glue.getMinimumSize(), new Dimension(0, Short.MAX_VALUE/4), glue.getMaximumSize());
add(glue);
}
public void refresh()
{
JPanel parent = (JPanel)getParent();
CardLayout cardLayout = (CardLayout)parent.getLayout();
parent.add(new ViewPanel(discussion), "A");
cardLayout.show(parent, "A");
parent.remove(0);
OperationPanel.save();
}
}