diff --git a/src/main/java/info/istlab/IoTP/MqttWindow.java b/src/main/java/info/istlab/IoTP/MqttWindow.java index 994272c..f87a72a 100644 --- a/src/main/java/info/istlab/IoTP/MqttWindow.java +++ b/src/main/java/info/istlab/IoTP/MqttWindow.java @@ -124,6 +124,7 @@ // jta.requestFocus(); appendToJTA("まだ接続していません。Topicを設定してConnectをおしてください。\n"); } + @Override public void run() { subscriber = new MqttSubscriber(brokerjtf.getText(), brokerportjtf.getText(), topicjtf.getText(), this); @@ -141,10 +142,9 @@ appendToJTA("Connected.\n"); jta.setBackground(Color.white); topicjtf.setEditable(false); - connectB.setText("Disconnect"); + connectB.setText("Disconnect"); } - private void connect(ActionEvent e) { if (e.getActionCommand().equals("Connect")) { if (thread != null) { @@ -242,18 +242,18 @@ // } private void closeWin() { - if (subscriber == null) - return; - try { - subscriber.unsubscribe(); - } catch (MqttException | InterruptedException e1) { - e1.printStackTrace(); - } finally { - subscriber = null; - appendToJTA("Disconnected.\n"); - jta.setBackground(Color.gray); - MqttWindow.theMqttWindow = null; + if (subscriber != null) { + try { + subscriber.unsubscribe(); + } catch (MqttException | InterruptedException e1) { + e1.printStackTrace(); + } finally { + subscriber = null; + appendToJTA("Disconnected.\n"); + jta.setBackground(Color.gray); + } } + MqttWindow.theMqttWindow = null; connectB.setText("Connect"); if (Launcher.theapp == null || !Launcher.theapp.isVisible()) System.exit(0);