关于Applet事件响应与快捷键设置问题 高手请进!
请采用适配器方式的事件处理,完成下述功能:按窗口“关闭”按扭后,关闭窗口,并为save菜单设置ctrl+F4的快捷键。
以下是html和applet类 可以直接编译执行调试的。多谢各位高手
1.html
<body bgcolor= "000000 ">
<center>
<applet
code = "MenuDemo.class "
width = "500 "
height = "300 "
>
</applet>
</center>
</body>
2.MenuDemo.java
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
class MenuFrame extends Frame{
CheckboxMenuItem show;
MenuFrame(String title){
super(title);
MenuBar mbar = new MenuBar();
setMenuBar(mbar);
Menu file = new Menu( "File ");
MenuItem item1, item2,item3;
Menu sub=new Menu( "Fomat ");
MenuItem item10,item11;
sub.add(item10=new MenuItem( "FomatA "));
sub.add(item11=new MenuItem( "FomatB "));
file.add(sub);
item1=new MenuItem( "Save ");
// item1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,InputEvent.CTRL_MASK,false));
file.add(item1);
show=new CheckboxMenuItem( "show ");
file.add(show);
file.add(item2=new MenuItem( "- "));
file.add(item3=new MenuItem( "Quit "));
mbar.add(file);
Menu help = new Menu( "help ");
mbar.add(help);
}
}
public class MenuDemo extends java.applet.Applet {
Frame f;
public void init() {
f=new MenuFrame( "Menu ");
int width=Integer.parseInt(getParameter( "width "));
int height=Integer.parseInt(getParameter( "height "));
setSize(new Dimension(width,height));
f.setSize(width,height);
f.setVisible(true);
}
public void start(){
f.setVisible(true);
}
public void stop(){
f.setVisible(false);
}
}
------解决方案--------------------然后呢?