我有这样一个菜单:
JMenu forum = new JMenu("Forum");
forum.addMenuListener( new MenuListener(){
public void menuSelected(MenuEvent e) {
}
public void menuDeselected(MenuEvent e) {
}
public void menuCanceled(MenuEvent e) {
}
});
menubar.add(forum);
并且作为menuSelected操作,我想重定向到一个页面,例如page.html 我该怎么办?
答案 0 :(得分:0)
Desktop myDesktop=Desktop.getDesktop()
public void menuSelected(MenuEvent e) {
myDesktop.browse(uri);
}
代码下面使用Applet(我从here获取代码)
String link = "http://www."+source.getLabel()+".com";
try {
AppletContext a = getAppletContext();
URL url = new URL(link);
a.showDocument(url,"_blank");
}