/** Construct a this GUI object's contents. */
  private void initComponents() {
    htmlWindow = new JEditorPane();
    htmlWindow.setPreferredSize(new Dimension(500, 500));
    htmlWindow.setEditable(false);
    htmlWindow.setContentType("text/html");
    scrollPane =
        new JScrollPane(
            htmlWindow,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setPreferredSize(new Dimension(500, 500));

    try {
      htmlWindow.setPage("file:./html-docs/index.html");
    } catch (IOException ioe) {
      System.err.println(ioe);
    }
    htmlWindow.addHyperlinkListener(
        new HyperlinkListener() {
          public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
              try {
                htmlWindow.setPage(e.getURL()); // ?????
              } catch (IOException ioe) {
                System.err.println(ioe);
              }
            }
          }
        });

    JButton exitButton = new JButton("Close Help Window");
    exitButton.addActionListener(this);
    mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(exitButton, "North");
    mainPanel.add(scrollPane, "Center");
    getContentPane().add(mainPanel);
  }
Exemplo n.º 2
0
  /** Construct a new "about…" dialog */
  public DialogAbout(MDIManager mdimgr) {

    buttonOk = new JButton(localize("button.OK"));
    buttonOk.addActionListener(this);

    JPanel buttonPanel = new JPanel(new FlowLayout(), false);
    buttonPanel.add(buttonOk);

    JPanel logoPanel = new JPanel(new FlowLayout(), false);
    logoPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
    logoPanel.add(PEToolKit.createJLabel("Frankenstein"));

    JPanel infoPanel = new JPanel(new GridLayout(9, 1, 5, 5), true);
    infoPanel.setBorder(new EmptyBorder(10, 60, 10, 10));
    infoPanel.add(
        new JLabel("jPicEdt " + Version.getVersion() + " Built " + Version.getBuildDate()));
    infoPanel.add(new JLabel(localize("about.APictureEditorFor")));
    final String[] addressLines = {
      "(c) Sylvain Reynal",
      "É.N.S.É.A. - Dept. of Physics",
      "6, avenue du Ponceau",
      "F-95014 CERGY Cedex",
      "Fax: +33 (0) 130 736 667",
      "*****@*****.**",
      "http://www.jpicedt.org"
    };
    for (String addressLine : addressLines) infoPanel.add(new JLabel(addressLine));

    JTabbedPane caveatPanel = new JTabbedPane();
    String[] tabKeys = {"license.lines", "license.thirdparty.lines"};
    for (String tabKey : tabKeys) {
      JEditorPane caveatTA = new JEditorPane();
      caveatTA.setContentType("text/html; charset=" + localize(tabKey + ".encoding"));
      caveatTA.setEditable(false);
      caveatTA.setPreferredSize(new Dimension(485, 300));
      JScrollPane scrollCaveat = new JScrollPane(caveatTA);
      caveatTA.setText(localize(tabKey));
      caveatPanel.addTab(localize(tabKey + ".tabname"), null, scrollCaveat, null);
    }

    caveatPanel.setBorder(BorderFactory.createEtchedBorder());

    JPanel upperPanel = new JPanel(new BorderLayout(), false);
    upperPanel.add(logoPanel, BorderLayout.WEST);
    upperPanel.add(infoPanel, BorderLayout.CENTER);
    upperPanel.add(caveatPanel, BorderLayout.SOUTH);
    upperPanel.setBorder(BorderFactory.createEtchedBorder());

    JPanel contentPane = new JPanel(new BorderLayout(5, 5));
    contentPane.add(upperPanel, BorderLayout.NORTH);
    contentPane.add(buttonPanel, BorderLayout.SOUTH);

    String title = localize("about.AboutPicEdt") + " " + Version.getVersion();
    boolean modal = true;
    frame = mdimgr.createDialog(title, modal, contentPane);
    frame.setResizable(true);
    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    Dimension dlgSize = frame.getPreferredSize();
    frame.setSize(dlgSize);

    // this.pack();
    frame.setVisible(true);
  }