Perhaps you should start by reading the documentation for the appropriate classes.