This section changes the example program to display the concatenated character string in a JLabel component in a user interface to further illustrate the concepts of well-defined class boundaries and object cooperation. The program code to place the text in a label to display it in a user interface uses a number of cooperating classes. Each class has its own function and purpose as summarized below, and where appropriate, the classes are defined to work with objects of another class. ExampleProgram defines the program data and methods to work on that data. JFrame defines the top-level window including the window title and frame menu.
String defines a character string to create the label.
JLabel defines a user interface component to display static text. While each class has its own specific purpose, they all work together to create the simple user interface you see here. Inheritance One object-oriented concept that helps objects work together is inheritance. Inheritance defines relationships among classes in an object-oriented language. In the Java programming language, all classes descend from java.lang.Object and implement its methods.