Esempio n. 1
0
  public AboutController(JFrame owner) {
    view = new AboutView(owner);
    view.getEditorPaneAbout().setContentType("text/html");

    String aboutText = "";

    try {
      InputStream inputStream = this.getClass().getResourceAsStream(ABOUT_HTML);
      aboutText = String.format(IOUtils.toString(inputStream), FileResourceUtility.getVersion());
    } catch (Exception e) {
      JOptionPane.showMessageDialog(null, e);
    }

    view.getEditorPaneAbout().setText(aboutText);

    view.getEditorPaneAbout()
        .addHyperlinkListener(
            new HyperlinkListener() {
              @Override
              public void hyperlinkUpdate(HyperlinkEvent evt) {
                if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                  try {
                    Desktop.getDesktop().browse(evt.getURL().toURI());
                  } catch (Exception e) {
                    // If we can't open the URL we just ignore it (no error
                    // message)
                  }
                }
              }
            });

    view.getEditorPaneAbout().setCaretPosition(0);

    view.getBtnOK()
        .addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent arg0) {
                view.dispose();
              }
            });

    view.getRootPane().setDefaultButton(view.getBtnOK());
    view.getBtnOK().requestFocus();

    view.setSize(600, 400);
    view.setVisible(true);
  }