aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2014-02-24 21:02:34 +0100
committerPacien TRAN-GIRARD2014-02-24 21:02:34 +0100
commit7f153a4c1a9cd294b516067a4950d54f9c7d10d2 (patch)
tree039522d30c4a2667753f83d76f49b9a5148689b0
parent818d0e52340f9c32ab3c85d97c1a433de3eb3402 (diff)
downloadesieequest-7f153a4c1a9cd294b516067a4950d54f9c7d10d2.tar.gz
Add a help button
-rw-r--r--src/esieequest/UserInterface.java20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/esieequest/UserInterface.java b/src/esieequest/UserInterface.java
index 949348e..0168b33 100644
--- a/src/esieequest/UserInterface.java
+++ b/src/esieequest/UserInterface.java
@@ -96,22 +96,27 @@ public class UserInterface implements ActionListener {
96 JPanel vPanel = new JPanel(); 96 JPanel vPanel = new JPanel();
97 this.aImage = new JLabel(); 97 this.aImage = new JLabel();
98 98
99 JButton vButtonHelp = new JButton("?");
100 vButtonHelp.setActionCommand("help");
101
99 vPanel.setLayout(new BorderLayout()); 102 vPanel.setLayout(new BorderLayout());
100 vPanel.add(this.aImage, BorderLayout.NORTH); 103 vPanel.add(this.aImage, BorderLayout.NORTH);
101 vPanel.add(vListScroller, BorderLayout.CENTER); 104 vPanel.add(vListScroller, BorderLayout.CENTER);
102 vPanel.add(this.aEntryField, BorderLayout.SOUTH); 105 vPanel.add(this.aEntryField, BorderLayout.SOUTH);
106 vPanel.add(vButtonHelp, BorderLayout.WEST);
103 107
104 this.aMyFrame.getContentPane().add(vPanel, BorderLayout.CENTER); 108 this.aMyFrame.getContentPane().add(vPanel, BorderLayout.CENTER);
105 109
106 // add some event listeners to some components 110 // add some event listeners to some components
111 this.aEntryField.addActionListener(this);
112 vButtonHelp.addActionListener(this);
113
107 this.aMyFrame.addWindowListener(new WindowAdapter() { 114 this.aMyFrame.addWindowListener(new WindowAdapter() {
108 public void windowClosing(WindowEvent pEvent) { 115 public void windowClosing(WindowEvent pEvent) {
109 System.exit(0); 116 System.exit(0);
110 } 117 }
111 }); 118 });
112 119
113 this.aEntryField.addActionListener(this);
114
115 this.aMyFrame.addWindowListener(new WindowAdapter() { 120 this.aMyFrame.addWindowListener(new WindowAdapter() {
116 public void windowClosing(WindowEvent e) { 121 public void windowClosing(WindowEvent e) {
117 killFrame(); 122 killFrame();
@@ -127,21 +132,16 @@ public class UserInterface implements ActionListener {
127 * Actionlistener interface for entry textfield. 132 * Actionlistener interface for entry textfield.
128 */ 133 */
129 public void actionPerformed(ActionEvent pEvent) { 134 public void actionPerformed(ActionEvent pEvent) {
130 // no need to check the type of action at the moment. 135 processCommand(pEvent.getActionCommand());
131 // there is only one possible action: text entry
132 processCommand();
133 } 136 }
134 137
135 /** 138 /**
136 * A command has been entered. Read the command and do whatever is necessary 139 * A command has been entered. Read the command and do whatever is necessary
137 * to process it. 140 * to process it.
138 */ 141 */
139 private void processCommand() { 142 private void processCommand(final String pInput) {
140 boolean vFinished = false;
141 String vInput = this.aEntryField.getText();
142 this.aEntryField.setText(""); 143 this.aEntryField.setText("");
143 144 this.aEngine.interpretCommand(pInput);
144 this.aEngine.interpretCommand(vInput);
145 } 145 }
146 146
147 public void killFrame() { 147 public void killFrame() {