private void browseButton_actionPerformed(ActionEvent e) { if (logger.isInfoEnabled()) { logger.info("browse button clicked"); } try { String urlString = urlTextField.getText(); if (urlString == null || urlString.trim().length() == 0) { throw new MalformedURLException("You must specify a url."); } new URL(urlString); // may throw MalformedURLException BrowserLauncherErrorHandler errorHandler = new TestAppErrorHandler(debugTextArea); // use browser list if browserListField has data String browserItems = browserListField.getText(); if (browserItems != null && browserItems.length() > 0) { logger.debug("using browser list"); String[] browserArray = browserItems.split("[ ]+"); List browserList = Arrays.asList(browserArray); logger.debug(browserList.toString()); launcher.openURLinBrowser(browserList, urlString); } else { String targetBrowser = browserBox.getSelectedItem().toString(); logger.debug(targetBrowser); launcher.openURLinBrowser(targetBrowser, urlString); } } catch (Exception ex) { // capture exception BrowserLauncherTestApp.updateDebugTextArea(ex, debugTextArea); // show message to user JOptionPane.showMessageDialog( this, ex.getMessage(), "Error Message", JOptionPane.ERROR_MESSAGE); } }
public void handleException(Exception ex) { // capture exception BrowserLauncherTestApp.updateDebugTextArea(ex, debugTextArea); // show message to user JOptionPane.showMessageDialog( JOptionPane.getRootFrame(), ex.getMessage(), "Error Message", JOptionPane.ERROR_MESSAGE); }
public static void main(String[] args) { BrowserLauncherTestApp app = new BrowserLauncherTestApp(); app.pack(); app.setVisible(true); }