getContentPane().setLayout(new BorderLayout());
getContentPane().add("Center", close);
// add a menu bar
MenuBar mb = new MenuBar();
Menu file = new Menu("File");
file.setShortcut(new MenuShortcut(KeyEvent.VK_F, true));
MenuItem tmp;
file.add(tmp = new MenuItem("Connect"));
tmp.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
pluginLoader.broadcast(new SocketRequest(host,
Integer.parseInt(port)));
}
});
file.add(tmp = new MenuItem("Disconnect"));
tmp.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
pluginLoader.broadcast(new SocketRequest());
}
});
file.add(new MenuItem("-"));
file.add(tmp = new MenuItem("Print"));
tmp.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (pluginLoader.getComponents().get("Terminal") != null) {
PrintJob printJob =
appletFrame.getContentPane().getToolkit()
.getPrintJob((JFrame) appletFrame, "JTA Terminal", null);
((Component) pluginLoader.getComponents().get("Terminal"))
.print(printJob.getGraphics());
printJob.end();
}
}
});
file.add(new MenuItem("-"));
file.add(tmp = new MenuItem("Exit"));
tmp.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
((JFrame) appletFrame).setVisible(false);
pluginLoader.broadcast(new SocketRequest());
close.setLabel(startText != null ? startText : "Connect");
}
});
mb.add(file);
Menu edit = new Menu("Edit");
edit.setShortcut(new MenuShortcut(KeyEvent.VK_E, true));
edit.add(tmp = new MenuItem("Copy"));
tmp.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (debug > 2)
System.err.println("Applet: copy: " + focussedPlugin);
if (focussedPlugin instanceof VisualTransferPlugin)
((VisualTransferPlugin) focussedPlugin).copy(clipboard);
}
});
edit.add(tmp = new MenuItem("Paste"));
tmp.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (debug > 2)
System.err.println("Applet: paste: " + focussedPlugin);
if (focussedPlugin instanceof VisualTransferPlugin)
((VisualTransferPlugin) focussedPlugin).paste(clipboard);
}
});
mb.add(edit);
Map menuList = pluginLoader.getMenus();
names = menuList.keySet().iterator();
while (names.hasNext()) {
String name = (String) names.next();
Object o = menuList.get(name);
if (o instanceof Menu) mb.add((Menu) o);
}
Menu help = new Menu("Help");
help.setShortcut(new MenuShortcut(KeyEvent.VK_HELP, true));
help.add(tmp = new MenuItem("General"));
tmp.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Help.show(appletFrame.getContentPane(), options.getProperty("Help.url"));
}
});
mb.setHelpMenu(help);
// only add the menubar if the property is true
if ((new Boolean(options.getProperty("Applet.detach.menuBar"))
.booleanValue()))
((JFrame) appletFrame).setMenuBar(mb);