When the thread worker invokes the method start , the run method is called automatically, and it executes the JDBC code in the thread worker . The code in run is very similar to the code you have seen in our other sample code with three exceptions. First, it uses the class Vector to store the results of the query. Second, it does not print out the results but rather adds them to the Vector results for display later. Third, it likewise does not print out exceptions and instead records error messages for later display.
Applets have various ways of drawing, or displaying, their content.
The method paint is what actually displays something on the screen, and in OutputApplet.java , it is defined to contain calls to the method drawString . When there are no query results to display, drawString will display the current contents of the String message . The last two methods defined in the class OutputApplet, setError and setResults are private, which means that they can be used only by OutputApplet . These methods both invoke the method repaint , which clears the screen and calls paint . So if setResults calls repaint , the query results will be displayed, and if setError calls repaint , an error message will be displayed.