From 7f153a4c1a9cd294b516067a4950d54f9c7d10d2 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Mon, 24 Feb 2014 21:02:34 +0100 Subject: Add a help button --- src/esieequest/UserInterface.java | 20 ++++++++++---------- 1 file 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 { JPanel vPanel = new JPanel(); this.aImage = new JLabel(); + JButton vButtonHelp = new JButton("?"); + vButtonHelp.setActionCommand("help"); + vPanel.setLayout(new BorderLayout()); vPanel.add(this.aImage, BorderLayout.NORTH); vPanel.add(vListScroller, BorderLayout.CENTER); vPanel.add(this.aEntryField, BorderLayout.SOUTH); + vPanel.add(vButtonHelp, BorderLayout.WEST); this.aMyFrame.getContentPane().add(vPanel, BorderLayout.CENTER); // add some event listeners to some components + this.aEntryField.addActionListener(this); + vButtonHelp.addActionListener(this); + this.aMyFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent pEvent) { System.exit(0); } }); - this.aEntryField.addActionListener(this); - this.aMyFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { killFrame(); @@ -127,21 +132,16 @@ public class UserInterface implements ActionListener { * Actionlistener interface for entry textfield. */ public void actionPerformed(ActionEvent pEvent) { - // no need to check the type of action at the moment. - // there is only one possible action: text entry - processCommand(); + processCommand(pEvent.getActionCommand()); } /** * A command has been entered. Read the command and do whatever is necessary * to process it. */ - private void processCommand() { - boolean vFinished = false; - String vInput = this.aEntryField.getText(); + private void processCommand(final String pInput) { this.aEntryField.setText(""); - - this.aEngine.interpretCommand(vInput); + this.aEngine.interpretCommand(pInput); } public void killFrame() { -- cgit v1.2.3