This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Okay, title probably isn't helpful. But here's the scoop. I know this is probably a dumb question, but I've never worked with threads in Java, and want to make sure I go about this properly. I currently have an applet which is a combination of JComponents, which I define paintComponents for, and can add JComponents to. My main drawing canvas supports drawing, adding components with mouseclicks, and most interactivity. My problem is, when I animate something (without threads), it's like doLayout() isn't being called, and all components on this component's layout manager don't appear while animating. Animation is very crude using a loop, Thread.sleep, and paintComponent. Which is why I want to thread it. The problem gets very bad, when I have a machine that takes in inputs, and provides output. The input happens to be a JTextArea, and while the machine is "churning", it's supposed to look like this JTextArea is getting slowly consumed by the machine. My problem is, my crude animation means none of the JComponent family are displayed during animation, and hence, no machine eating the JTextArea. So, what I want to know, is how can I Thread this thing and have it animate properly. If you need to know the structure, it's a JApplet, with a JComponent laid on top of it, and the animation occurs within the JComponent. In the JComponent I've defined paintComponent. Nothing else, well nothing else pertaining to drawing to the Graphics context. I'm sorry if I'm too descriptive. I was having a hard time writing this succinctly. I appreciate any help you can provide!