I have a program in which a JPanel is added to a JFrame:
public class Test{ Test2 test = new Test2(); JFrame frame = new JFrame(); Test(){ ...
Test2 test = new Test2(); ... frame.add(test, BorderLayout.CENTER);
Are you sure of this? test is NOT a component! To do what you're trying to do you should let Test2 extend JPanel !
test
Test2
JPanel