* Initializes the frame menu.
*/
private void initializeMenu() {
Menu menu;
MenuItem item;
CheckboxMenuItem checkBox;
// Create file menu
menu = new Menu("File");
item = new MenuItem("Load MIB...", new MenuShortcut(KeyEvent.VK_O));
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
loadMib();
}
});
menu.add(item);
item = new MenuItem("Unload MIB", new MenuShortcut(KeyEvent.VK_W));
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
unloadMib();
}
});
menu.add(item);
item = new MenuItem("Unload All");
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
unloadAllMibs();
}
});
menu.add(item);
if (!MacUIHelper.IS_MAC_OS) {
menu.addSeparator();
item = new MenuItem("Exit", new MenuShortcut(KeyEvent.VK_Q));
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
quit();
}
});
menu.add(item);
}
menuBar.add(menu);
// Create Edit menu
menu = new Menu("Edit");
item = new MenuItem("Cut", new MenuShortcut(KeyEvent.VK_X));
item.addActionListener(new DefaultEditorKit.CutAction());
menu.add(item);
item = new MenuItem("Copy", new MenuShortcut(KeyEvent.VK_C));
item.addActionListener(new DefaultEditorKit.CopyAction());
menu.add(item);
item = new MenuItem("Paste", new MenuShortcut(KeyEvent.VK_V));
item.addActionListener(new DefaultEditorKit.PasteAction());
menu.add(item);
item = new MenuItem("Select All", new MenuShortcut(KeyEvent.VK_A));
item.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
KeyboardFocusManager kfm =
KeyboardFocusManager.getCurrentKeyboardFocusManager();
Component comp = kfm.getFocusOwner();
if (comp instanceof TextComponent) {
((TextComponent) comp).selectAll();
} else if (comp instanceof JTextComponent) {
((JTextComponent) comp).selectAll();
}
}
});
menu.add(item);
menuBar.add(menu);
// Create SNMP menu
menu = new Menu("SNMP");
snmpV1Item.setState(true);
snmpV1Item.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
setSnmpVersion(1);
}
});
menu.add(snmpV1Item);
snmpV2Item.setState(false);
snmpV2Item.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
setSnmpVersion(2);
}
});
menu.add(snmpV2Item);
snmpV3Item.setState(false);
snmpV3Item.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
setSnmpVersion(3);
}
});
menu.add(snmpV3Item);
menu.addSeparator();
checkBox = new CheckboxMenuItem("Show result in tree");
checkBox.setState(true);
checkBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
setSnmpFeedback(e.getStateChange() == ItemEvent.SELECTED);
}
});
menu.add(checkBox);