コード例 #1
0
 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);
   }
 }
コード例 #2
0
 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();
   }
 }
コード例 #3
0
 private void windowPolicyItemStateChange(ItemEvent e) {
   launcher.setNewWindowPolicy(e.getStateChange() == ItemEvent.SELECTED);
 }