JPanels on Layered Pane don't appear where i want.
Hello. I'm working on a interface to a program that teaches kid's
mathematics. My menu base on JPanels that are grouped intu
JLayeredPane. Each JPanel have it's depth. I would like to do that if
a Pannel appear on top of the others(is active) it covers all the
frame. Unfortunately it don't want to cover it. It leaves few pixels
space like on the image HERE:
http://img152.imageshack.us/img152/6595/explainpicvc5.jpg
CODE:
public Main(){
//creating layered pane
layeredPane = new JLayeredPane();
layeredPane.setPreferredSize(new Dimension(FRAME_WIDTH,FRAME_HEIGHT));
//create pannel and add it to layered pane
Point origin = new Point(0, 0);
panelMenu = createColoredPanel(origin);
panelMenu.setVisible(false);
layeredPane.add(panelMenu, new Integer(4),0);
}
//method that creates panel
private JPanel createColoredPanel(/*Color color,*/ Point origin){
JPanel panel =new JPanel(new GridBagLayout());
panel.setOpaque(true);
panel.setVisible(false);
panel.setBounds(origin.x, origin.y-5, rozmiarPanela , rozmiarPanela);
return panel;
}