Create the class files and image files
In Eclipse® or in a text editor, create the following three .java files to represent the different parts of our application:
- CustomButton.java: This file will contain the main application class, CustomButton. This class will contain the main() method, which is the entry point to our application.
- CustomButtonScreen.java: This file will contain the class that represents the screen in our application, CustomButtonScreen. This screen is displayed when the application starts, and will contain the fields, managers, and other components that will make up the UI of our application.
- CustomButtonField.java: This file will contain the class that represents our custom button. This class will contain all of the methods that are required to draw the graphical elements of the button (such as border, background, and text) as well as the methods that determine how these graphical elements are arranged.
You should also create the following three PNG image files:
- custom_normal.png: This image will represent the border and background of the button when it does not have the focus on the screen.
- custom_focus.png: This image will represent the border and background of the button when it has the focus, but is not pressed.
- custom_active.png: This image will represent the border and background of the button when the BlackBerry® device user presses the button.
In this tutorial, we'll use the following three images: