@Override public void actionPerformed(ActionEvent e) { Tools.openURL("http://wiki.languagetool.org/finding-errors-using-n-gram-data"); } });
@Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { Tools.openURL(e.getURL()); } } });
/** * Launches the default browser to display a URL. * * @param url the URL to be displayed * @since 4.1 */ static void openURL(String url) { try { openURL(new URL(url)); } catch (MalformedURLException ex) { Tools.showError(ex); } }
private JPanel getWord2VecPanel(GridBagConstraints cons) { JPanel panel = new JPanel(); panel.add(new JLabel(messages.getString("guiWord2VecDir")), cons); File dir = config.getWord2VecDirectory(); int maxDirDisplayLength = 45; String buttonText = dir != null ? StringUtils.abbreviate(dir.getAbsolutePath(), maxDirDisplayLength) : messages.getString("guiWord2VecDirSelect"); JButton word2vecDirButton = new JButton(buttonText); word2vecDirButton.addActionListener(e -> { File newDir = Tools.openDirectoryDialog(owner, dir); if (newDir != null) { try { config.setWord2VecDirectory(newDir); word2vecDirButton.setText(StringUtils.abbreviate(newDir.getAbsolutePath(), maxDirDisplayLength)); } catch (Exception ex) { Tools.showErrorMessage(ex); } } else { // not the best UI, but this way user can turn off word2vec feature without another checkbox config.setWord2VecDirectory(null); word2vecDirButton.setText(StringUtils.abbreviate(messages.getString("guiWord2VecDirSelect"), maxDirDisplayLength)); } }); panel.add(word2vecDirButton, cons); JButton helpButton = new JButton(messages.getString("guiWord2VecHelp")); helpButton.addActionListener(e -> { Tools.openURL("https://github.com/gulp21/languagetool-neural-network"); }); panel.add(helpButton, cons); return panel; }