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); } }
private void copyButton_actionPerformed(ActionEvent e) { if (logger.isInfoEnabled()) { logger.info("copy button clicked"); } debugTextArea.selectAll(); debugTextArea.copy(); debugTextArea.select(0, 0); }
private void loggingLevelBttn_actionPerformed(ActionEvent e) { String[] levels = logger.getLevelOptions(); int levelIndex = logger.getLevel(); String level = (String) JOptionPane.showInputDialog( this, bundle.getString("logging.level.select.message"), bundle.getString("logging.level.select.title"), JOptionPane.QUESTION_MESSAGE, null, levels, levels[levelIndex]); if (level != null && level.length() > 0) { levelIndex = -1; for (int idx = 0, max = levels.length; idx < max && levelIndex == -1; idx++) { if (level.equals(levels[idx])) { levelIndex = idx; } } logger.setLevel(levelIndex); loggingLevelTxtFld.setText(logger.getLevelText()); } }
public BrowserLauncherTestApp() { super(); try { bundle = ResourceBundle.getBundle(debugResources); logger = initDebugLogging(); loggingLevelTxtFld.setText(logger.getLevelText()); super.setTitle(bundle.getString("label.app.title")); populateDebugInfo(bundle, debugTextArea); launcher = new BrowserLauncher(logger, new TestAppErrorHandler(debugTextArea)); ComboBoxModel cbModel = new DefaultComboBoxModel(launcher.getBrowserList().toArray()); browserBox.setModel(cbModel); windowPolicyCBox.setSelected(launcher.getNewWindowPolicy()); jbInit(); } catch (Exception ex) { ex.printStackTrace(); } }