I am trying to add a jinternal frame to a frame that is in full screen exclusive mode. However when i add it it fills up the whole screen with white. Here is my code.
JFrame f = new JFrame();
f.setTitle("Platform Game");
f.setLocationRelativeTo(null);
f.setUndecorated(true);
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice gs = ge.getDefaultScreenDevice();
gs.setFullScreenWindow(f);
f.setVisible(true);
createFrame(f);
protected static void createFrame(JFrame f)
{
JInternalFrame frame = new JInternalFrame("Options", false, true, false, false);
frame.setVisible(true);
frame.setSize(10, 10);
frame.setLocation(10, 10);
JDesktopPane pane = new JDesktopPane();
pane.add(frame);
f.setContentPane(pane);
try
{
frame.setSelected(true);
}
catch (java.beans.PropertyVetoException e)
{
e.printStackTrace();
}
}
If anyone knows how to do this properly please post it, or tell me what i am doing wrong.
Details
OS : windows 7
JDK : jdk 1.7.0_11
IDE : eclipse
I am using a panel on the jframe, and i am drawing on the panel
painting code
public void paintComponent(Graphics g)
{
super.paintComponent(g);
for(int i = 0; i<1000; i++)
g.drawImage(bi, i*bi.getWidth()-getXs(), 0, bi.getWidth(), Main.HEIGHT, null);
g.setColor(Color.WHITE);
for(int x = 0; x<Main.X_TILES; x++)
{
for(int y = 0; y<Main.Y_TILES; y++)
{
Block block = map[x][y];
if(block!=null && x*Block.WIDTH>=xs-Block.WIDTH && x*Block.WIDTH<=xs+Main.WIDTH)
g.drawImage(block.getImage(x,y), x*Block.WIDTH-getXs(), y*Block.HEIGHT, Block.WIDTH, Block.HEIGHT, null);
}
}
for(Entity entity : entities)
{
if(entity!=null && entity.getX()>=xs-Block.WIDTH && entity.getX()<=xs+Main.WIDTH)
g.drawImage(entity.getImage(), entity.getX()-getXs(), entity.getY(), entity.getWidth(), entity.getHeight(), null);
}
if(displayDebug)
{
g.drawString("Free memory "+Runtime.getRuntime().freeMemory()/1024+" KB", 10, 12);
g.drawString("Total memory "+Runtime.getRuntime().totalMemory()/1024+" KB", 10, 24);
g.drawString("Max memory "+Runtime.getRuntime().maxMemory()/1024+" KB", 10, 36);
g.drawString("X "+character.getX(), 10, 48);
g.drawString("Y "+character.getY(), 10, 60);
g.drawString("XS "+xs, 10, 72);
}
g.setColor(Color.BLACK);
g.drawString("Life "+character.getHealth(), 700, 12);
g.dispose();
}
I saw an answer to a similar question JInternalFrame in full-screen mode that said to put it directly on panel but i tried that and it still didn't work.
EDIT: When i commented out my painting code, and i added it directly to the panel instead it worked, however it wouldn't drag around, so my new question is how do i make it appear when a paint job is being done. Is their a way to draw a component on using paint component?
For clarification it still didn't work normally when added to the panel without the painting code.