CommandPanel hinzugefügt
authorfelix <felix@a944a559-bf0e-0410-8ddc-85264b264b6c>
Tue, 15 May 2007 17:54:31 +0000 (17:54 +0000)
committerfelix <felix@a944a559-bf0e-0410-8ddc-85264b264b6c>
Tue, 15 May 2007 17:54:31 +0000 (17:54 +0000)
git-svn-id: https://www.internetallee.de/svn/bytewurf@21 a944a559-bf0e-0410-8ddc-85264b264b6c

projekte/netzschalter/src/de/bytewurf/projekte/netzschalter/CommandPanel.java [new file with mode: 0644]
projekte/netzschalter/src/de/bytewurf/projekte/netzschalter/NetzdosenApplet.java

diff --git a/projekte/netzschalter/src/de/bytewurf/projekte/netzschalter/CommandPanel.java b/projekte/netzschalter/src/de/bytewurf/projekte/netzschalter/CommandPanel.java
new file mode 100644 (file)
index 0000000..974ef4d
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * 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("");
+       }
+       
+       
+}
index 6b7db09..63a59a8 100644 (file)
@@ -39,8 +39,9 @@ public class NetzdosenApplet extends Applet {
 
                JTabbedPane modePanel = new JTabbedPane();
 
-               modePanel.add("LED", new NetzdosenLEDPanel(netzdose));
                modePanel.add("Config", new ConfigPanel(netzdose));
+               modePanel.add("LED", new NetzdosenLEDPanel(netzdose));
+               modePanel.add("Commands", new CommandPanel(netzdose));
                JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
                splitPane.add(modePanel, JSplitPane.TOP);