java 请看下面代码。为什么菜单条出不来??菜鸟上路,求高手教学
importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;publicclassMainFrameexten...
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class MainFrame extends JFrame
{
private static int WIDTH=200;
private static int HEIGHT=300;
private JMenuBar myMenuBar;
private JMenu GameMenu;
private JMenu HelpMenu;
/*
private JMenuItem opening;
private JMenuItem gameset;
private JMenuItem set;
private JMenuItem charts;
private JMenuItem exit;
*/
private JMenuBar getmyMenuBar(){
if(myMenuBar==null){
myMenuBar=new JMenuBar();
myMenuBar.add(getGameMenu());
myMenuBar.add(HelpMenu);
}
return myMenuBar;
}
private JMenu getGameMenu(){
if(GameMenu==null){
GameMenu=new JMenu();
GameMenu.setText("游戏");
}
return GameMenu;
}
public MainFrame(){
setTitle("扫雷");
setSize(WIDTH,HEIGHT);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setJMenuBar(getmyMenuBar());
}
public static void main(String args[]){
MainFrame myframe=new MainFrame();
}
} 展开
import java.awt.event.*;
import javax.swing.*;
public class MainFrame extends JFrame
{
private static int WIDTH=200;
private static int HEIGHT=300;
private JMenuBar myMenuBar;
private JMenu GameMenu;
private JMenu HelpMenu;
/*
private JMenuItem opening;
private JMenuItem gameset;
private JMenuItem set;
private JMenuItem charts;
private JMenuItem exit;
*/
private JMenuBar getmyMenuBar(){
if(myMenuBar==null){
myMenuBar=new JMenuBar();
myMenuBar.add(getGameMenu());
myMenuBar.add(HelpMenu);
}
return myMenuBar;
}
private JMenu getGameMenu(){
if(GameMenu==null){
GameMenu=new JMenu();
GameMenu.setText("游戏");
}
return GameMenu;
}
public MainFrame(){
setTitle("扫雷");
setSize(WIDTH,HEIGHT);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setJMenuBar(getmyMenuBar());
}
public static void main(String args[]){
MainFrame myframe=new MainFrame();
}
} 展开
展开全部
public class MainFrame extends JFrame
{
private static int WIDTH=200;
private static int HEIGHT=300;
private JMenuBar myMenuBar;
private JMenu GameMenu;
private JMenu HelpMenu;
/*
private JMenuItem opening;
private JMenuItem gameset;
private JMenuItem set;
private JMenuItem charts;
private JMenuItem exit;
*/
private JMenuBar getmyMenuBar(){
if(myMenuBar==null){
HelpMenu = new JMenu("帮助");
myMenuBar=new JMenuBar();
myMenuBar.add(getGameMenu());
myMenuBar.add(HelpMenu);
}
return myMenuBar;
}
private JMenu getGameMenu(){
if(GameMenu==null){
GameMenu=new JMenu();
GameMenu.setText("游戏");
}
return GameMenu;
}
public MainFrame(){
setTitle("扫雷");
setSize(WIDTH,HEIGHT);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setJMenuBar(getmyMenuBar());
}
public static void main(String args[]){
MainFrame myframe=new MainFrame();
}
}
可以的 我这能显示
{
private static int WIDTH=200;
private static int HEIGHT=300;
private JMenuBar myMenuBar;
private JMenu GameMenu;
private JMenu HelpMenu;
/*
private JMenuItem opening;
private JMenuItem gameset;
private JMenuItem set;
private JMenuItem charts;
private JMenuItem exit;
*/
private JMenuBar getmyMenuBar(){
if(myMenuBar==null){
HelpMenu = new JMenu("帮助");
myMenuBar=new JMenuBar();
myMenuBar.add(getGameMenu());
myMenuBar.add(HelpMenu);
}
return myMenuBar;
}
private JMenu getGameMenu(){
if(GameMenu==null){
GameMenu=new JMenu();
GameMenu.setText("游戏");
}
return GameMenu;
}
public MainFrame(){
setTitle("扫雷");
setSize(WIDTH,HEIGHT);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setJMenuBar(getmyMenuBar());
}
public static void main(String args[]){
MainFrame myframe=new MainFrame();
}
}
可以的 我这能显示
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你漏写了一句话。
追问
请问我漏写了什么?谢谢
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询