简单的问题 - 我正在编辑一个基于 java 的 MMORPG 游戏,并想在游戏框架中添加一个菜单栏。所以我做了,但菜单栏似乎切入了游戏并阻止了一些内容,因此它隐藏在菜单栏后面。这里有一个示例图片:
这是我的代码的图片:
public GameFrame(GameWindow gameWindow, int width, int height, String title, boolean resizable, boolean flag1) {
frameOffset = 28;
frameWidth = width;
frameHeight = height - 1;
aGameWindow = gameWindow;
addListeners(this, gameWindow);
if (flag1)
frameOffset = 48;
else
frameOffset = 28;
setTitle(title);
setResizable(resizable);
menubar = new MenuBar();
menu = new java.awt.Menu("Menu");
submenu = new java.awt.Menu("Sub Menu");
m1 = new MenuItem("Menu Item 1");
m2 = new MenuItem("Menu Item 2");
m3 = new MenuItem("Menu Item 3");
m4 = new MenuItem("Menu Item 4");
m5 = new MenuItem("Menu Item 5");
menu.add(m1);
menu.add(m2);
menu.add(m3);
submenu.add(m4);
submenu.add(m5);
menu.add(submenu);
menubar.add(menu);
setMenuBar(menubar);
this.addWindowListener(new WindowListener() {
@Override
public void windowActivated(WindowEvent arg0) {}
@Override
public void windowClosed(WindowEvent arg0) {
System.exit(-1);
}
@Override
public void windowClosing(WindowEvent arg0) {
System.exit(-1);
}
@Override
public void windowDeactivated(WindowEvent arg0) {}
@Override
public void windowDeiconified(WindowEvent arg0) {}
@Override
public void windowIconified(WindowEvent arg0) {}
@Override
public void windowOpened(WindowEvent arg0) {}
});
show();
toFront();
resize(frameWidth, frameHeight);
aGraphics49 = getGraphics();
}
关于如何解决这个问题的任何想法,或者在顶部创建一些额外的空间以便它不会干扰游戏?
谢谢