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;
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() {
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("");
}
-
-
+
}