--- /dev/null
+/*
+ * Created on 15.05.2007
+ *
+ * To change this generated comment go to
+ * Window>Preferences>Java>Code Generation>Code Template
+ */
+package de.bytewurf.projekte.netzschalter;
+
+import java.awt.BorderLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+
+/**
+ * @author felix
+ */
+public class CommandPanel extends JPanel {
+
+ private Netzdose netzdose;
+
+ private int commandCounter;
+
+ private JButton apply;
+ private JButton reset;
+
+ private JLabel commandLabel;
+ private JTextField command;
+ private JLabel answersLabel;
+ private JTextArea answers;
+
+ public CommandPanel(Netzdose netzdose) {
+ this.netzdose = netzdose;
+
+ setLayout(new BorderLayout());
+
+ JPanel top = new JPanel();
+ top.setLayout(new BorderLayout());
+ commandLabel = new JLabel("Command:");
+ top.add(commandLabel, BorderLayout.WEST);
+ command = new JTextField();
+ top.add(command, BorderLayout.CENTER);
+ add(top, BorderLayout.NORTH);
+
+ JPanel middle = new JPanel();
+ middle.setLayout(new BorderLayout());
+ commandCounter = 0;
+ answersLabel = new JLabel("Answers:");
+ middle.add(answersLabel, BorderLayout.WEST);
+ answers = new JTextArea();
+ answers.setEditable(false);
+ middle.add(new JScrollPane(answers, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
+ JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED), BorderLayout.CENTER);
+ add(middle, BorderLayout.CENTER);
+
+ JPanel bottom = new JPanel();
+ apply = new JButton("apply");
+ apply.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ apply();
+ }
+ });
+ bottom.add(apply);
+
+ reset = new JButton("reset");
+ reset.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ reset();
+ }
+ });
+ bottom.add(reset);
+ add(bottom, BorderLayout.SOUTH);
+ }
+
+ protected void reset() {
+ command.setText("");
+ }
+
+ protected void apply() {
+ LogMediator.getInstance().log("Sende " + command.getText());
+ answers.append(++commandCounter + ": " + command.getText() + "\n");
+ command.setText("");
+ }
+
+
+}