forked from YUR0ii/Red-Group
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommentPage.java
More file actions
112 lines (89 loc) · 2.91 KB
/
CommentPage.java
File metadata and controls
112 lines (89 loc) · 2.91 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
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
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.ScrollPaneConstants;
import java.awt.ComponentOrientation;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
public class CommentPage extends JFrame {
private String currentText;
private JSplitPane sp;
private JPanel topPanel;
private JPanel bottomPanel;
private JScrollPane scroll;
private JTextArea textArea;
private JPanel inputPanel;
private JButton commit;
private JButton delete;
private JLabel title;
CommentPage(String CT){
currentText = CT;
setLocation(500,300);
sp = new JSplitPane();
topPanel = new JPanel();
bottomPanel = new JPanel();
textArea = new JTextArea();
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
textArea.setText(currentText);
scroll = new JScrollPane(textArea);
scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
title = new JLabel("Edit Comment");
topPanel.add(title);
inputPanel = new JPanel();
commit = new JButton("Commit");
commit.setPreferredSize(new Dimension(199,25));
delete = new JButton("Delete");
delete.setPreferredSize(new Dimension(199,25));
setPreferredSize(new Dimension(400, 400));
getContentPane().add(sp);
sp.setOrientation(JSplitPane.VERTICAL_SPLIT);
sp.setTopComponent(topPanel);
sp.setBottomComponent(bottomPanel);
topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.X_AXIS));
bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.Y_AXIS));
bottomPanel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
bottomPanel.add(scroll);
bottomPanel.add(inputPanel);
inputPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, 75));
inputPanel.setLayout(new BoxLayout(inputPanel, BoxLayout.X_AXIS));
inputPanel.add(commit);
inputPanel.add(delete);
pack();
initiateComponents();
setVisible(true);
}
public String getText() {
return currentText;
}
private void initiateComponents() {
textArea.addKeyListener(new KeyListener(){
public void keyPressed(KeyEvent e) {}
public void keyReleased(KeyEvent e) {}
public void keyTyped(KeyEvent arg0) {
currentText = textArea.getText();
}
});
commit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
currentText = textArea.getText();
dispose();
}
});
delete.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
currentText = "";
dispose();
}
});
}
}