Creating Your Own Component
An advantage of OOP is the capability to reuse classes in different projects. For the next project, you create a special panel component that you can reuse in other Java programs. The component, ClockPanel, displays the current date and time in a manner similar to the ClockTalk project from Hour 7, “Using Conditional Tests to Make Decisions.”
The first step in creating your own user interface component is to decide the existing component from which to inherit. The ClockPanel component is a subclass of JPanel.
The ClockPanel class is defined in Listing 13.3. This class represents panel components that include a label displaying the current date and time. Enter the text from Listing 13.3 into a new empty Java file and ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access