From: felix Date: Thu, 17 May 2007 14:20:22 +0000 (+0000) Subject: - Code Formatierung durch Eclipse X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=d54a8bd4b9ede823719dbc3ebce6f8ad75ee4b3b;p=bytewurf.git - Code Formatierung durch Eclipse - ActionListener für Command Field git-svn-id: https://www.internetallee.de/svn/bytewurf@34 a944a559-bf0e-0410-8ddc-85264b264b6c --- 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(""); } - - + }