This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
You have several choices, really. One is to create a method in the Main class that takes the buffer in as a parameter and does work with it. The 'least amount of work' would be something like this:
Then you call that method when you need to:
Of course, the method is static here as an example. In a real-life case you might need to make it an instance method with all the related necessity of making that instance available to the method which calls it. This is especially true if you will have a GUI or some other class/Object which needs to work with the data. Personally, I would model it as a Listener. Make an interface method which takes a byte, then make Main implement the interface and do something with the byte. The make TwoWaySerialComm and SerialReader accept 'Listener's and have the SerialReader call the appropriate method when the data is read.
Joined: Nov 06, 2010
Thanks for your reply, as this is my 1st Java project, the 2nd choice is hard to understand at the moment.
I tried the 1st one and did get it to print to the console the contents of buffer from my Main Class.
But then tried to print it to my jTextArea from my main method, but because its in a different method it couldn't find the symbol variable "buffer"
Which is what you said would happen, i think?