I will post the code I use in Java Tutorials here for reference and for others to see what I have done.