I have created two classes in my package named ball and toop . and want to add them in my third class whitch extends JFrame . I did but objects didnt display in a JFrame when I use Container . and without Container only one of them added to JFrame . here is my code :
package mytry;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import javax.swing.*;
public class trypanel extends JFrame {
JFrame frame = new JFrame();
Container panel = new Container();
public trypanel(){
toop c = new toop();
ball a = new ball(20,20,1);
frame.setVisible(true);
frame.setSize(550,550);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
panel.add(c);
panel.add(a);
frame.getContentPane().add(panel);
c.run();
}
}
How can I add my classes to the JFrame ??