/** Initializes the frame components. */ private void initialize() { GridBagConstraints c; // Set title, size and menus setDefaultCloseOperation(EXIT_ON_CLOSE); setTitle("Mibble MIB Browser"); Dimension size = Toolkit.getDefaultToolkit().getScreenSize(); Rectangle bounds = new Rectangle(); bounds.width = (int) (size.width * 0.75); bounds.height = (int) (size.height * 0.75); bounds.x = (size.width - bounds.width) / 2; bounds.y = (size.height - bounds.height) / 2; setBounds(bounds); setMenuBar(menuBar); initializeMenu(); getContentPane().setLayout(new GridBagLayout()); // Add horizontal split pane JSplitPane horizontalSplitPane = new JSplitPane(); horizontalSplitPane.setDividerLocation((int) (bounds.width * 0.35)); c = new GridBagConstraints(); c.weightx = 1.0d; c.weighty = 1.0d; c.fill = GridBagConstraints.BOTH; getContentPane().add(horizontalSplitPane, c); // Add status label c = new GridBagConstraints(); c.gridy = 1; c.fill = GridBagConstraints.BOTH; c.insets = new Insets(2, 5, 2, 5); getContentPane().add(statusLabel, c); // Add MIB tree mibTree = MibTreeBuilder.getInstance().getTree(); mibTree.addTreeSelectionListener( new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { updateTreeSelection(); } }); horizontalSplitPane.setLeftComponent(new JScrollPane(mibTree)); // Add description area & SNMP panel JSplitPane verticalSplitPane = new JSplitPane(); verticalSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); verticalSplitPane.setDividerLocation((int) (bounds.height * 0.40)); verticalSplitPane.setOneTouchExpandable(true); descriptionArea.setEditable(false); verticalSplitPane.setLeftComponent(new JScrollPane(descriptionArea)); snmpPanel = new SnmpPanel(this); verticalSplitPane.setRightComponent(snmpPanel); horizontalSplitPane.setRightComponent(verticalSplitPane); }
/** * Sets the selected node based on the specified OID. The MIB that will be searched is based on * the currently selected MIB node. * * @param oid the OID to select */ public void setSelectedNode(String oid) { // Find tree node MibValueSymbol symbol = browser.findMibSymbol(oid); MibNode node = MibTreeBuilder.getInstance().getNode(symbol); if (node == null) { mibTree.clearSelection(); return; } // Select tree node TreePath path = new TreePath(node.getPath()); mibTree.expandPath(path); mibTree.scrollPathToVisible(path); mibTree.setSelectionPath(path); mibTree.repaint(); }