求助,照着书上打的代码,但运行结果不一样,很多没没显示出来,代码里import static javax.swing.JFrame.*;左边有感叹号,这些都是为啥呀
public class Example9_2 {
public static void main(String args[]) {
WindowMenu win = new WindowMenu("带菜单的窗口",20,30,200,190);
}
}
import javax.swing.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import static javax.swing.JFrame.*;
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) {
init(s);
setLocation(x,y);
setVisible(true);
setSize(w,h);
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}
void init(String s) {
setTitle(s);
menubar = new JMenuBar();
menu = new JMenu("菜单");
subMenu = new JMenu("软件项目");
item1 = new JMenuItem("Java话题",new ImageIcon("1.jpg"));
item2 = new JMenuItem("动画话题",new ImageIcon("2.jpg"));
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("3.jpg")));
subMenu.add(new JMenuItem("农场信息系统",new ImageIcon("4.jpg")));
menubar.add(menu);
setJMenuBar(menubar);
}
}