public class PubPanel extends Object implements ActionListener, DocumentListener
File input
When input is read from a file the input is stored in a separate buffer called fileContent
as the file contents may not be diplayable in the JTextArea (e.g. a binary file). When a file is read
the contents are written to the JTextArea, although it is the fileContent byte array that will get published,
not the window contents.
To know when the fileContent array is out of date (i.e the JTextArea data has been modified) a DocumentListener is
added to the JTextArea upon reading the file. The first change event from the JTextArea clears the fileContent array
and removes the DocumentListener, so that data is now read directly from the JTextArea again.
Constructor and Description |
---|
PubPanel(JPanel thePubPanel,
MQTTFrame aMqttMgr)
The constructor for the publication panel
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(ActionEvent e)
ActionListener interface
Listen out for the Publish button, the Hex/Text button being pressed or the File button being pressed Publishing data involves: Converting the data to a character representation if necessary from hex Updating the drop down boxes with the topic if necessary Publishing the data Converting the data back to a hex representation if necessary Writing a log entry Processing the File button involves reading the file contents into a buffer ready for publishing. |
void |
changedUpdate(DocumentEvent de)
DocumentListener - changedUpdate
The JTextArea has been modified.
|
void |
enableButtons(boolean b)
This enables or disables the publish button depending on the value of the boolean.
|
void |
init()
The init method builds all the required components and adds them to the
publication panel.
|
void |
insertUpdate(DocumentEvent de)
DocumentListener - insertUpdate
Performs the same functionality as changedUpdate above.
|
void |
removeUpdate(DocumentEvent de)
DocumentListener - removeUpdate
Performs the same functionality as changedUpdate above.
|
boolean |
updateTopicList(String topicName)
For any requests to add a topic to the subscribe drop down box
use the updateComboBoxList method in class MQTTFrame to do the job.
|
public void init()
public boolean updateTopicList(String topicName)
public void actionPerformed(ActionEvent e)
actionPerformed
in interface ActionListener
public void enableButtons(boolean b)
b
- Button enabled if true, otherwise disabled.public void changedUpdate(DocumentEvent de)
changedUpdate
in interface DocumentListener
public void insertUpdate(DocumentEvent de)
insertUpdate
in interface DocumentListener
public void removeUpdate(DocumentEvent de)
removeUpdate
in interface DocumentListener
Copyright © 2016 Eclipse Paho. All rights reserved.