The framework is drawn in the paint method. We draw the title and labels in their appropriate places. We draw a vertical line at the left border of the graph drawing region, and a horizontal line at the bottom border. In this next snippet we set the preferred size for the component by overriding the preferredSize method. The preferredSize method is also inherited from the Component class.
Components can specify a preferred size and a minimum size.
I have chosen a preferred width of 300 and a preferred height of 200. The layout manager will call this method when it lays out the component. Next, we need a facility for adding and removing the items to be graphed. I've modeled the addItem and removeItem methods after similar methods in the Choice class, so the code will have a familiar feel. When an item is added, a new GraphItem object is created and added to the items vector.