From d54a8bd4b9ede823719dbc3ebce6f8ad75ee4b3b Mon Sep 17 00:00:00 2001 From: felix Date: Thu, 17 May 2007 14:20:22 +0000 Subject: [PATCH] =?utf8?q?-=20Code=20Formatierung=20durch=20Eclipse=20-=20?= =?utf8?q?ActionListener=20f=C3=BCr=20Command=20Field?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: https://www.internetallee.de/svn/bytewurf@34 a944a559-bf0e-0410-8ddc-85264b264b6c --- .../projekte/netzschalter/CommandPanel.java | 41 ++++++++++++++-------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/projekte/netzschalter/src/de/bytewurf/projekte/netzschalter/CommandPanel.java b/projekte/netzschalter/src/de/bytewurf/projekte/netzschalter/CommandPanel.java index 58bfd66..584dfce 100644 --- a/projekte/netzschalter/src/de/bytewurf/projekte/netzschalter/CommandPanel.java +++ b/projekte/netzschalter/src/de/bytewurf/projekte/netzschalter/CommandPanel.java @@ -23,30 +23,40 @@ import javax.swing.JTextField; 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(); + command.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + apply(); + } + }); top.add(command, BorderLayout.CENTER); add(top, BorderLayout.NORTH); - + JPanel middle = new JPanel(); middle.setLayout(new BorderLayout()); commandCounter = 0; @@ -54,10 +64,12 @@ public class CommandPanel extends JPanel { 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); + 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() { @@ -87,14 +99,15 @@ public class CommandPanel extends JPanel { try { cmd = new Command(commandText); } catch (RuntimeException e) { - LogMediator.getInstance(this.getClass()).log("Kann \"" + commandText + "\" nicht in Command wandeln."); + LogMediator.getInstance(this.getClass()).log( + "Kann \"" + commandText + "\" nicht in Command wandeln."); return; } LogMediator.getInstance(this.getClass()).log("Sende " + cmd); byte[] answerBytes = netzdose.sendCommand(cmd); - answers.append(++commandCounter + ": " + new Command(answerBytes).toString() + "\n"); + answers.append(++commandCounter + ": " + + new Command(answerBytes).toString() + "\n"); command.setText(""); } - - + } -- 2.11.0