Reputation: 1
I am trying to write a simple GUI and it is my first time using swing. I am trying to use getComponents() for a frame so that I can have access to one of its panels. However, I am getting the error "symbol not found" for the method. I have looked at some other posts about similar issues for getComponent(int i) and they said to import javax.faces.event.ActionEvent, but that did not work for me. Do you have any suggestions/solutions, does anything in my code stick out as blatantly incorrect?
Thanks! My code is below:
public void componentResized(ComponentEvent e)
{
Component f = e.getComponent();
Dimension d = f.getBounds().getSize();
System.out.println("Width: " + d.getWidth());
System.out.println("Height: " + d.getHeight());
Component components[] = f.getComponents();
}
Upvotes: 0
Views: 181
Reputation: 1356
getComponents is the method of java.awt.Container, not java.awt.Component maybe you can try
if(f instanceof Container) {
Component components[] = ((Container)f).getComponents();
}
Upvotes: 2