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 package org.ximtec.igesture.geco.gui;
27
28 import java.awt.Color;
29 import java.awt.Dimension;
30 import java.awt.GridBagConstraints;
31 import java.awt.GridBagLayout;
32 import java.awt.GridLayout;
33 import java.awt.Insets;
34
35 import javax.swing.JPanel;
36 import javax.swing.JScrollPane;
37 import javax.swing.JTextPane;
38 import javax.swing.border.BevelBorder;
39 import javax.swing.border.TitledBorder;
40
41 import org.ximtec.igesture.geco.util.Constant;
42
43
44
45
46
47
48
49 public class CommandView extends JPanel {
50
51 private JTextPane textField;
52
53
54 public CommandView() {
55 populate();
56 init();
57 }
58
59
60 public String getCommand() {
61 return textField.getText();
62 }
63
64
65
66
67
68
69
70 public void updateView(String command) {
71 textField.setText(command);
72 }
73
74
75
76
77
78 public void init() {
79 textField.setText(Constant.EMPTY_STRING);
80 }
81
82
83 private void populate() {
84 this.setLayout(new GridBagLayout());
85 JPanel aPanel = new JPanel();
86 aPanel.setLayout(new GridLayout());
87 aPanel.setBorder(new TitledBorder(new BevelBorder(0, Color.gray,
88 Color.gray), Constant.COMMAND));
89 textField = new JTextPane();
90 JScrollPane scrollPane = new JScrollPane();
91 scrollPane.getViewport().add(textField);
92 textField.setMaximumSize(new Dimension(300, 200));
93 textField.setBorder(new BevelBorder(0, Color.gray, Color.gray));
94 aPanel.add(scrollPane);
95
96 this.add(aPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
97 GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(40,
98 20, 40, 20), 0, 0));
99 }
100
101 }