我正在嘗試將jinternal幀添加到全屏獨佔模式下的幀。但是,當我添加它填充整個屏幕與白色。這是我的代碼。將JInternalFrame添加到fsem幀
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();
}
}
如果有人知道如何正確地做到這一點,請發佈它,或告訴我我做錯了什麼。
詳細
操作系統:Windows 7
JDK:JDK 1.7.0_11
IDE:日食
我使用JFrame中一個面板,我繪製在面板上
油漆代碼
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();
}
我看到類似問題的答案JInternalFrame in full-screen mode,說它直接放在面板上,但我試過了,但仍然無法工作。
編輯:當我評論了我的繪畫代碼,並且我直接將它添加到面板而不是它的工作,但它不會拖動,所以我的新問題是如何使它出現在繪畫作品正在完成。他們是使用繪畫組件繪製組件的方法嗎?
澄清它沒有繪製代碼添加到面板時仍然無法正常工作。
我沒有問題與得到的示例工作,除了調整大小或移動內部框架。你在 – MadProgrammer
下運行什麼操作系統和JDK的Windows 7 jdk 1.7.0_11 –
如果你正在做自定義繪畫,你需要提出的是你的例子以及 – MadProgrammer