import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;
/**
* You are not including all your imports. For example,
* where is the LayoutManager import.
*/
public class Panel extends Component {
private LayoutManager layoutManager;
private Component[] layout;
/**
* you have to use the Java documentation that I sent
* you. LayoutManager is an interface and cannot be
* instantiated. To create an instance, you must use
* an object from one of LayoutManager's subclasses.
* I already provided you this example in our conversation.
*/
public Panel(LayoutManager layoutManager) {
this.layoutManager =new LayoutManager();
}
/**
* I addressed this in the conversation back on the site.
* layoutManager doesn't have an add(); method. I mentioned
* of the two examples I would use the panel object for the
* invocation of the add method.
*/
public void addComponent(Component component) {
layoutManager.add(component, layoutManager);
}
/**
* you can't use the type to qualify the invocation of a method
* but you must first create an instance of that type and use that
* instance to invoke a method. That is unless the method is a
* static method.
*/
public Component[] getComponents() {
return Panel.getComponents();
}
/**
* go back to the site and read what I have already mentioned
*/
public void layout() {
layoutManager.layout(this);
}
public int getPreferredWidth() {
return layoutManager.getPreferredWidth(this);
}
public int getPreferredHeight() {
return layoutManager.getPreferredHeight(this);
}
/**
* go back to the site and read what I have already mentioned
*/
public String toString() {
return "";
}
}