// I have two classes One is Carnivore and the other is Herbivore. Each of them is having its own shape and move function across the screen. Now i want to put them togehter in the following Environment Class so that i can see them moving across the screen simultaneously. But this function is giving me a blank screen if i try to add both of those classes. If i add just one class, it works. What am i doing wrong in this Java coding? import javax.swing.JFrame; import javax.swing.JPanel; public class Environment { public static Environment earth; public Environment() { Carnivore s = new Carnivore(); Herbivore h = new Herbivore(); JFrame f = new JFrame(); JPanel pane = new JPanel(); pane.add(s); pane.add(h); f.add(pane); f.setVisible(true); f.setSize(600,400); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setTitle(\"The Jungle Life\"); } } Solution Modified your code... you should have main method, then we have to create and panel and add this panel to frame import javax.swing.JFrame; import javax.swing.JPanel; public class Environment { //frame instance declared public JFrame f; //constructor public Environment(){ prepareGUI(); } //main method public static void main(String args[]){ Environment earth = new Environment(); earth.showEnvironment(); } //preparing frame in this method public void prepareGUI() { f = new JFrame(); f.setVisible(true); f.setSize(600,400); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setTitle(\"The Jungle Life\"); } //then finally adding this frame to panel public void showEnvironment(){ //creating carnivore and herbivore objects Carnivore s = new Carnivore(); Herbivore h = new Herbivore(); JPanel panel = new JPanel(); panel.add(s); panel.add(h); f.add(panel); f.setVisible(true); } } .