/* * This file is part of the Remote Sensor Actuator Interface (ReSAI). * * Copyright(c) Andreas Kipp, Frederic Siepmann * http://opensource.cit-ec.de/projects/resai * * This file may be licensed under the terms of of the * GNU Lesser General Public License Version 3 (the ``LGPL''), * or (at your option) any later version. * * Software distributed under the License is distributed * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either * express or implied. See the LGPL for the specific language * governing rights and limitations. * * You should have received a copy of the LGPL along with this * program. If not, go to http://www.gnu.org/licenses/lgpl.html * or write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * The development of this software was supported by the * Excellence Cluster EXC 277 Cognitive Interaction Technology. * The Excellence Cluster EXC 277 is a grant of the Deutsche * Forschungsgemeinschaft (DFG) in the context of the German * Excellence Initiative. * */ /** * Panel for the speech actuator. * * @author akipp */ package de.unibi.airobots.resaijavaclient.gui.panels.components; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.HashMap; import java.util.Observable; import javax.swing.JButton; import javax.swing.JTextArea; import javax.swing.JTextField; import de.unibi.airobots.resaijavaclient.gui.panels.components.template.PanelTemplate; public class TalkPanel extends PanelTemplate implements ActionListener { private static final long serialVersionUID = 1L; private JTextArea txaMessages = new JTextArea(40,100); private JTextField txtMessage = new JTextField(100); private JButton btnSend = new JButton("Say it"); public TalkPanel() { setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = 0; c.weightx = 100; add(txtMessage, c); c.gridx = 0; c.gridy = 1; add(btnSend, c); c.ipady = 10; btnSend.addActionListener(this); c.gridx = 0; c.gridy = 2; add(txaMessages, c); } @Override public void update(Observable arg0, Object arg1) { // TODO Auto-generated method stub } @Override public void actionPerformed(ActionEvent arg0) { if(txtMessage.getText().length() > 0) { HashMap propertiesToSend = new HashMap(); propertiesToSend.put("TAG", "SpeechActuatorThread"); propertiesToSend.put("SpeechActuatorThread", "True"); propertiesToSend.put("SPEECH", txtMessage.getText()); overviewController.sendMessage(propertiesToSend); txaMessages.append("\n" + txtMessage.getText()); } } }