void jButtonOK_actionPerformed(ActionEvent e) { logger.logComment("OK button pressed"); cancelled = false; double threshold; try { threshold = Double.parseDouble(jTextFieldThreshold.getText()); } catch (NumberFormatException ex) { GuiUtils.showErrorMessage( logger, "Please enter a number (usually -50 -> 0) for the millivolt value of the firing threshold", ex, this); return; } mySynProps.setThreshold(threshold); String selectedSynapse = (String) jComboBoxSynapseType.getSelectedItem(); mySynProps.setSynapseType(selectedSynapse); this.dispose(); }
/** Constructor - creates layout. */ public HelpFrame() { setTitle("Web-Harvest Help"); setIconImage(((ImageIcon) ResourceManager.HELP32_ICON).getImage()); this.topNode = new DefaultMutableTreeNode(); this.treeModel = new DefaultTreeModel(this.topNode); try { String helpContent = CommonUtil.readStringFromUrl(ResourceManager.getHelpContentUrl()); XmlNode xmlNode = XmlParser.parse(new InputSource(new StringReader(helpContent))); createNodes(topNode, xmlNode); } catch (Exception e) { e.printStackTrace(); GuiUtils.showErrorMessage("Error reading help content!"); } tree = new JTree(topNode); tree.setRootVisible(false); tree.setShowsRootHandles(true); tree.setBorder(new EmptyBorder(5, 5, 5, 5)); tree.setCellRenderer( new DefaultTreeCellRenderer() { public Component getTreeCellRendererComponent( JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) super.getTreeCellRendererComponent( tree, value, sel, expanded, leaf, row, hasFocus); if (value instanceof DefaultMutableTreeNode) { DefaultMutableTreeNode defaultMutableTreeNode = (DefaultMutableTreeNode) value; Object userObject = defaultMutableTreeNode.getUserObject(); if (userObject instanceof TopicInfo) { TopicInfo topicInfo = (TopicInfo) userObject; renderer.setIcon( topicInfo.subtopicCount == 0 ? ResourceManager.HELPTOPIC_ICON : ResourceManager.HELPDIR_ICON); } } return renderer; } }); tree.addTreeSelectionListener(this); htmlPane = new JEditorPane(); htmlPane.setEditable(false); htmlPane.setContentType("text/html"); htmlPane.setEditorKit(new HTMLEditorKit()); htmlPane.setBorder(new EmptyBorder(5, 5, 5, 5)); JSplitPane splitPane = new ProportionalSplitPane(JSplitPane.HORIZONTAL_SPLIT); splitPane.setResizeWeight(0.0d); splitPane.setBorder(null); JScrollPane treeScrollPane = new WHScrollPane(tree); treeScrollPane.getViewport().setBackground(Color.white); treeScrollPane.setBackground(Color.white); splitPane.setLeftComponent(treeScrollPane); splitPane.setRightComponent(new WHScrollPane(htmlPane)); splitPane.setDividerLocation(0.3d); Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); contentPane.add(splitPane, BorderLayout.CENTER); pack(); }