I am here trying to make a Snake-Food game. In this game Snake tries to eat as much food as he can. It is just a prototype. At the onset I added a Rectangle (emulating Snake) into the JFrame, it is functioning properly, i.e. when I press Up, Down, etc buttons. the rectangle moves to that direction. Then I tried adding a small Rectangle(emulating Food) into the JFrame but it was visible nowhere. I also tried using Box layout to satisfy my need but it bifurcates whole JFrame to give half to Snake and half to Food, having no relation at all. Please suggest what can I do to avoid this mess and how to add relation between Snake and Food. Snake must eat the food, but in my program as Snake reaches near the food, it seems as if it's going behind any surface and disappears inches away from food.

Start by doing some debugging. Add some println statements to the code to show you what it is doing.
For example in the paintComponent() methods print out where the drawing is being done and where the component is located.

A problem could be the use of components for the shapes. Consider where the layout manager is putting those components.