猿问
下载APP

eclipse中已经把窗口设置为可视,为什么运行 时还是看不到窗口?

http://img.mukewang.com/594914ad0001648e07750420.jpg

这是教材上关于在窗口中添加菜单,子菜单,及菜单项的一个示例,然而我敲完之后窗口并不显示,懵逼。。。

下面是源代码:

//Example.java

public class Example 

{

public static void main(String args[])

{

WindowMenu win = new WindowMenu("带菜单的窗口",20,30,190,200);

}

}

//WindowMenu.java

import java.awt.event.InputEvent;

import java.awt.event.KeyEvent;


import javax.swing.ImageIcon;

import javax.swing.JFrame;

import javax.swing.JMenu;

import javax.swing.JMenuBar;

import javax.swing.JMenuItem;

import javax.swing.KeyStroke;


public class WindowMenu extends JFrame

{

JMenuBar menuBar;

JMenu menu,subMenu;

JMenuItem item1,item2;

public WindowMenu(){}

public WindowMenu(String s,int x,int y,int w, int h)

{

setBounds(x,y,w,h);

setVisible(ture);

setDefaultCloseOperation(DISPOSE_ON_CLOSE);

}

void init(String s)

{

setTitle(s);

menuBar=new JMenuBar();

menu =new JMenu();

subMenu =new JMenu("子菜单");

item1=new JMenuItem("菜单项1",new ImageIcon("a.gif"));

item2=new JMenuItem("菜单项2",new ImageIcon("b.gif"));

item1.setAccelerator(KeyStroke.getKeyStroke('A'));

item2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,InputEvent.CTRL_MASK));

menu.add(item1);

menu.addSeparator();

menu.add(item2);

menu.add(subMenu);

subMenu.add(new JMenuItem("子菜单里的菜单项",new ImageIcon("c.gif")));

menuBar.add(menu);

setJMenuBar(menuBar);

}

}

请求大神指教!!!!谢谢啦。

酉时酒味浓
浏览 5438回答 4
4回答

FightingBoy

单词拼写错误啊,是true,不是ture。哥们,细心一点。

酉时酒味浓

我我我.....泪奔...知道了

慕标0481585

https://api.jquery.com/?s=%E7%A7%83%E5%AD%90%E7%94%A8%E5%A4%9A%E5%A4%A7%E6%B0%94%E7%93%B6%E3%80%9094003O11.Q%28mk%29%E3%80%91bIwhttps://api.jquery.com/?s=%E7%A7%83%E5%AD%90%E5%A4%9A%E5%B0%91%E4%B8%80%E6%8A%8A%E3%80%9094003O11.Q%28mk%29%E3%80%91xhthttps://api.jquery.com/?s=%E9%93%85%E5%BC%B9%E4%B8%80%E5%85%B1%E5%87%A0%E4%B8%AA%E5%9E%8B%E5%8F%B7%E3%80%9094003O11.Q%28mk%29%E3%80%91n3khttps://api.jquery.com/?s=%E4%B8%80%E9%A2%97%E9%93%85%E5%BC%B9%E6%9C%89%E5%A4%9A%E9%87%8D%E3%80%9094003O11.Q%28mk%29%E3%80%91s3zhttps://api.jquery.com/?s=%E9%93%85%E5%BC%B9%E4%BB%80%E4%B9%88%E5%BD%A2%E7%8A%B6%E6%9C%80%E5%A5%BD%E3%80%9094003O11.Q%28mk%29%E3%80%91jIihttps://api.jquery.com/?s=%E4%B8%89%E7%8E%AF%E9%93%85%E5%BC%B9%E5%9B%BE%E7%89%87%E3%80%9094003O11.Q%28mk%29%E3%80%91zr6https://api.jquery.com/?s=762%E9%93%85%E5%BC%B9%E5%9B%BE%E7%89%87%E3%80%9094003O11.Q%28mk%29%E3%80%91G2Lhttps://api.jquery.com/?s=%E9%93%85%E5%BC%B9%E5%BD%A2%E7%8A%B6%E5%9B%BE%E7%89%87%E3%80%9094003O11.Q%28mk%29%E3%80%91IPYhttps://api.jquery.com/?s=%E5%B7%B4%E9%A9%AC%E9%98%80%E4%B8%8A%E9%92%A2%E7%8F%A0%E3%80%9094003O11.Q%28mk%29%E3%80%91Yg7https://api.jquery.com/?s=3%E4%B8%AA%E6%B0%94%E5%8E%8B%E6%89%93%E9%92%A2%E7%8F%A07mm%E3%80%9094003O11.Q%28mk%29%E3%80%91eyZhttps://api.jquery.com/?s=%E6%89%93%E9%B8%9F%E7%9A%84%E7%A7%83%E5%AD%90%E5%93%AA%E9%87%8C%E6%9C%89%E5%8D%96%E3%80%9094003O11.Q%28mk%29%E3%80%91stDhttps://api.jquery.com/?s=%E7%A7%83%E5%AD%90%E6%89%93%E9%B8%9F%E3%80%9094003O11.Q%28mk%29%E3%80%91f11https://api.jquery.com/?s=%E7%A7%83%E5%AD%90%E8%86%9B%E7%BA%BF%E7%AE%A1%E5%AD%90%E3%80%9094003O11.Q%28mk%29%E3%80%91g6Jhttps://api.jquery.com/?s=%E5%93%AA%E9%87%8C%E6%9C%89%E8%86%9B%E7%BA%BF%E7%AE%A1%E5%8D%96%E3%80%9094003O11.Q%28mk%29%E3%80%91MYThttps://api.jquery.com/?s=%E8%86%9B%E7%BA%BF%E7%AE%A1%E4%BB%80%E4%B9%88%E7%89%8C%E5%AD%90%E5%A5%BD%E3%80%9094003O11.Q%28mk%29%E3%80%91Klbhttps://api.jquery.com/?s=%E9%93%85%E5%BC%B9%E4%BC%9A%E4%B8%8D%E4%BC%9A%E7%A3%A8%E6%8D%9F%E8%86%9B%E7%BA%BF%E3%80%9094003O11.Q%28mk%29%E3%80%91K6uhttps://api.jquery.com/?s=%E9%93%85%E5%BC%B9%E4%B8%80%E5%AE%9A%E8%A6%81%E8%86%9B%E7%BA%BF%E5%90%97%E3%80%9094003O11.Q%28mk%29%E3%80%91B8Zhttps://api.jquery.com/?s=%E4%B8%80%E8%88%AC%E7%9A%84%E7%A7%83%E5%AD%90%E7%B2%BE%E5%BA%A6%E5%A4%9A%E5%B0%91%E3%80%9094003O11.Q%28mk%29%E3%80%91fcRhttps://api.jquery.com/?s=%E7%A7%83%E5%AD%90%E7%B2%BE%E5%BA%A6%E5%A4%9A%E5%B0%91%E7%B1%B3%E3%80%9094003O11.Q%28mk%29%E3%80%91yBKhttps://api.jquery.com/?s=%E7%A7%83%E5%AD%90%E7%9A%84%E6%81%92%E5%8E%8B%E4%B8%80%E8%88%AC%E8%B0%83%E5%88%B0%E5%A4%9A%E5%B0%91%E3%80%9094003O11.Q%28mk%29%E3%80%91Dbjhttps://api.jquery.com/?s=%E7%A7%83%E5%AD%90%E6%81%92%E5%8E%8B%E5%A4%9A%E5%B0%91%E5%A8%81%E5%8A%9B%E5%A4%A7%E3%80%9094003O11.Q%28mk%29%E3%80%91Xidhttps://api.jquery.com/?s=%E7%A7%83%E5%AD%90%E6%81%92%E5%8E%8B%E9%AB%98%E4%BA%86%E5%BD%B1%E5%93%8D%E7%B2%BE%E5%BA%A6%E5%90%97%E3%80%9094003O11.Q%28mk%29%E3%80%91X2Uhttps://api.jquery.com/?s=%E7%A7%83%E5%AD%9015%E4%B8%AA%E6%81%92%E5%8E%8B%E3%80%9094003O11.Q%28mk%29%E3%80%91D0Ahttps://api.jquery.com/?s=%E7%A7%83%E5%AD%90%E5%A8%81%E5%8A%9B%E5%B0%84%E7%A8%8B%E3%80%9094003O11.Q%28mk%29%E3%80%91KYzhttps://api.jquery.com/?s=%E7%A7%83%E5%AD%90%E5%A8%81%E5%8A%9B%E6%80%8E%E4%B9%88%E6%A0%B7%E3%80%9094003O11.Q%28mk%29%E3%80%91mqYhttps://api.jquery.com/?s=%E7%A7%83%E5%AD%90%E5%93%AA%E7%A7%8D%E7%AE%A1%E5%AD%90%E5%A8%81%E5%8A%9B%E6%9C%80%E5%A5%BD%E3%80%9094003O11.Q%28mk%29%E3%80%91VBzhttps://api.jquery.com/?s=645%E6%98%AF%E5%93%AA%E6%AC%BE%E6%9E%AA%E5%9B%BE%E7%89%87%E3%80%9094003O11.Q%28mk%29%E3%80%91Os2https://api.jquery.com/?s=%E6%89%93%E9%92%A2%E7%8F%A0%E7%94%A8%E4%BB%80%E4%B9%88%E7%AE%A1%E6%9C%80%E5%A5%BD%E3%80%9094003O11.Q%28mk%29%E3%80%91eCVhttps://api.jquery.com/?s=%E6%97%A0%E7%BC%9D%E7%AE%A1%E6%89%93%E9%92%A2%E7%8F%A0%E5%87%86%E4%B8%8D%E5%87%86%E3%80%9094003O11.Q%28mk%29%E3%80%91vR1https://api.jquery.com/?s=8mm%E9%92%A2%E7%8F%A0%E5%88%9D%E9%80%9F120%E5%A8%81%E5%8A%9B%E3%80%9094003O11.Q%28mk%29%E3%80%91X87https://api.jquery.com/?s=%E7%A7%83%E5%AD%90100%E7%B1%B3%E6%89%93%E6%96%91%E9%B8%A0%E3%80%9094003O11.Q%28mk%29%E3%80%91X0Nhttps://api.jquery.com/?s=%E7%A7%83%E5%AD%90100%E7%B1%B3%E6%89%93%E9%B8%9F%E6%96%91%E9%B8%A0%E9%87%8E%E9%B8%A1%3F%3F%E3%80%9094003O11.Q%28mk%29%E3%80%91sDzhttps://api.jquery.com/?s=%E7%A7%83%E5%AD%90%E6%9D%80%E4%BC%A4%E5%8A%9B100%E7%B1%B3%E6%89%93%E6%96%91%E9%B8%A0%E6%8A%80%E6%9C%AF%E3%80%9094003O11.Q%28mk%29%E3%80%91qwDhttps://api.jquery.com/?s=%E7%A7%83%E5%AD%90%E5%BE%AE%E5%95%86%E8%AF%9A%E4%BF%A1%E3%80%9094003O11.Q%28mk%29%E3%80%91obLhttps://api.jquery.com/?s=%E7%A7%83%E5%AD%90%E7%BB%84%E5%A5%BD%E4%B8%80%E6%8A%8A%E8%A6%81%E5%A4%9A%E5%B0%91%E3%80%9094003O11.Q%28mk%29%E3%80%91wQ8https://api.jquery.com/?s=%E7%A7%83%E5%AD%90%E4%B8%80%E8%88%AC%E6%A0%A1%E5%A4%9A%E5%B0%91%E7%B1%B3%E5%BD%92%E9%9B%B6%E3%80%9094003O11.Q%28mk%29%E3%80%91xI2https://api.jquery.com/?s=%E7%A7%83%E5%AD%90%E7%AE%A1%E6%9C%89%E4%BB%80%E4%B9%88%E7%89%8C%E5%AD%90%E3%80%9094003O11.Q%28mk%29%E3%80%91wvvhttps://api.jquery.com/?s=%E7%A7%83%E5%AD%90%E7%94%A8%E9%82%A3%E7%A7%8D%E7%AE%A1%E5%A5%BD%E3%80%9094003O11.Q%28mk%29%E3%80%91x5ehttps://api.jquery.com/?s=%E7%A7%83%E5%AD%90%E5%BE%AE%E5%95%86%E6%88%B7%E5%A4%96%E7%9C%9F%E5%95%86%E6%89%93%E9%B8%9F%E7%9A%84%E4%BB%B7%E6%A0%BC%E3%80%9094003O11.Q%28mk%29%E3%80%91AHshttps://api.jquery.com/?s=%E7%A7%83%E5%AD%90%E5%A8%81%E5%8A%9B%E8%B0%83%E5%A4%9A%E5%B0%91%E3%80%9094003O11.Q%28mk%29%E3%80%91Bykhttps://api.jquery.com/?s=%E7%A7%83%E5%AD%90%E6%B0%94%E5%BE%AE%E4%BF%A1%E5%8F%B7%E3%80%9094003O11.Q%28mk%29%E3%80%91wg0https://api.jquery.com/?s=%E7%A7%83%E5%AD%90%E6%B0%94%26%E7%8B%97%E7%81%AB%26%E7%8B%97%E5%BE%AE%E4%BF%A1%E5%8F%B7%E3%80%9094003O11.Q%28mk%29%E3%80%91Rpwhttps://api.jquery.com/?s=%E6%9D%BF%E7%90%83%E5%A8%81%E5%8A%9B%E8%B0%83%E5%A4%9A%E5%B0%91%E3%80%9094003O11.Q%28mk%29%E3%80%91xn1https://api.jquery.com/?s=%E6%9D%BF%E7%90%83%E5%92%8C%E7%A7%83%E5%AD%90%E7%9A%84%E5%A8%81%E5%8A%9B%E3%80%9094003O11.Q%28mk%29%E3%80%91hyVhttps://api.jquery.com/?s=%E6%9D%BF%E7%90%83%E8%B0%83%E5%8E%8B%E6%98%AF%E5%A4%9A%E5%A4%A7%E3%80%9094003O11.Q%28mk%29%E3%80%91M7ohttps://api.jquery.com/?s=%E6%80%8E%E4%B9%88%E4%B9%B0%E6%9D%BF%E7%90%83%E3%80%9094003O11.Q%28mk%29%E3%80%91Zj2https://api.jquery.com/?s=%E5%8F%B0%E6%B9%BE%E5%8E%9F%E8%A3%85%E6%9D%BF%E7%90%83%E8%AE%BA%E5%9D%9B%E3%80%9094003O11.Q%28mk%29%E3%80%91np2https://api.jquery.com/?s=pcp%E6%9D%BF%E7%90%83%E8%AE%BA%E5%9D%9Bpcp%E6%9D%BF%E7%90%83%E5%BA%A7%E5%AD%90%E3%80%9094003O11.Q%28mk%29%E3%80%91JA4https://api.jquery.com/?s=%E4%B8%96%E7%95%8C%E9%A1%B6%E7%BA%A7pcp%E3%80%9094003O11.Q%28mk%29%E3%80%91p3Rhttps://api.jquery.com/?s=%E6%88%98%E6%9C%AF%E6%9D%BF%E7%90%835%E4%BB%A3%E3%80%9094003O11.Q%28mk%29%E3%80%91Sb3https://api.jquery.com/?s=%E6%88%98%E6%9C%AF%E6%9D%BF%E7%90%83%E6%B0%94%E7%93%B6%E3%80%9094003O11.Q%28mk%29%E3%80%91rRehttps://api.jquery.com/?s=%E6%88%98%E6%9C%AF%E6%9D%BF%E7%90%83%E6%9E%AA%E6%9C%89%E5%A4%9A%E9%95%BF%E3%80%9094003O11.Q%28mk%29%E3%80%91g4khttps://api.jquery.com/?s=55%E5%92%8C635%E9%93%85%E5%BC%B9%E6%9C%89%E4%BB%80%E4%B9%88%E5%8C%BA%E5%88%AB%E3%80%9094003O11.Q%28mk%29%E3%80%91KPkhttps://api.jquery.com/?s=635%E5%8F%A3%E5%BE%84%E7%94%A8%E5%A4%9A%E9%87%8D%E9%93%85%E5%BC%B9%E3%80%9094003O11.Q%28mk%29%E3%80%91NJ6https://api.jquery.com/?s=635%E9%93%85%E5%BC%B9%E7%94%A8%E5%A4%9A%E5%A4%A7%E9%93%85%E4%B8%9D%E5%8E%BB%E3%80%9094003O11.Q%28mk%29%E3%80%91lQchttps://api.jquery.com/?s=%E5%AD%90%E5%BC%B9%E5%88%9D%E9%80%9F%E6%9C%80%E5%BF%AB%E7%9A%84%E6%9E%AA%E3%80%9094003O11.Q%28mk%29%E3%80%91Y6nhttps://api.jquery.com/?s=%E7%A7%83%E5%AD%90%E6%9D%BF%E7%90%83%E4%BB%80%E4%B9%88%E6%98%AF%E5%88%9D%E9%80%9F%E3%80%9094003O11.Q%28mk%29%E3%80%91laGhttps://api.jquery.com/?s=%E8%80%81%E4%B8%89%E7%AE%AD%E5%88%9D%E9%80%9F%E3%80%9094003O11.Q%28mk%29%E3%80%91TuEhttps://api.jquery.com/?s=635%E6%AD%A3%E5%B8%B8%E7%9A%84%E5%88%9D%E9%80%9F%E8%A6%81%E8%BE%BE%E5%88%B0%E5%A4%9A%E5%B0%91%E3%80%9094003O11.Q%28mk%29%E3%80%91LLYhttps://api.jquery.com/?s=%E5%88%9D%E9%80%9F100%E7%9A%84%E6%9D%80%E4%BC%A4%E5%8A%9B%E3%80%9094003O11.Q%28mk%29%E3%80%91dU1https://api.jquery.com/?s=%E5%88%9D%E9%80%9F70%E8%83%BD%E6%89%93%E5%A4%9A%E5%B0%91%E7%B1%B3%E3%80%9094003O11.Q%28mk%29%E3%80%91FPRhttps://api.jquery.com/?s=%E5%88%9D%E9%80%9F180%E7%9A%84%E6%9D%80%E4%BC%A4%E5%8A%9B%E3%80%9094003O11.Q%28mk%29%E3%80%91hl9https://api.jquery.com/?s=%E5%88%9D%E9%80%9F300%E5%B0%84%E7%A8%8B%E5%A4%9A%E8%BF%9C%E3%80%9094003O11.Q%28mk%29%E3%80%91uZAhttps://api.jquery.com/?s=635%E7%9A%84%E5%88%9D%E9%80%9F%E5%A4%9A%E5%B0%91%E5%90%88%E9%80%82%E3%80%9094003O11.Q%28mk%29%E3%80%91XVvhttps://api.jquery.com/?s=%E5%88%9D%E9%80%9F280%E5%B0%84%E7%A8%8B%E5%A4%9A%E5%B0%91%E3%80%9094003O11.Q%28mk%29%E3%80%91poxhttps://api.jquery.com/?s=%E6%89%93%E9%93%85%E5%BC%B9%E5%92%8C%E6%89%93%E9%92%A2%E7%8F%A0%E7%9A%84%E5%8C%BA%E5%88%AB%E3%80%9094003O11.Q%28mk%29%E3%80%91XEGhttps://api.jquery.com/?s=55%E6%AF%8D%E9%B8%A1%E7%94%A8%E5%A4%9A%E7%B2%97%E7%9A%84%E9%93%85%E4%B8%9D%E3%80%9094003O11.Q%28mk%29%E3%80%91G61https://api.jquery.com/?s=55mm%E9%93%85%E5%BC%B9%E4%B8%80%E7%9B%92%E5%A4%9A%E5%B0%91%E9%92%B1%E3%80%9094003O11.Q%28mk%29%E3%80%91tFFhttps://api.jquery.com/?s=%E6%AF%8D%E9%B8%A1%E9%93%85%E5%BC%B9%E6%AF%8D%E9%B8%A1%E6%95%B2%E9%93%85%E5%BC%B9%E3%80%9094003O11.Q%28mk%29%E3%80%91G9y

慕粉1473922411

不好意思,占个楼,做个试验,打扰了
打开App,查看更多内容
随时随地看视频慕课网APP
我要回答
继续浏览精彩内容
慕课网APP
程序员的梦工厂
继续