Ejemplo n.º 1
0
  protected void build() {
    help = new JEditorPane();
    HTMLEditorKit kit = new HTMLEditorKit();
    kit.setStyleSheet(buildStyleSheet());
    help.setEditorKit(kit);
    help.setEditable(false);
    help.addHyperlinkListener(new HyperlinkHandler());
    help.setContentType("text/html");
    history = new HelpBrowserHistory(this);

    JPanel p = new JPanel(new BorderLayout());
    setContentPane(p);

    p.add(spHelp = new JScrollPane(help), BorderLayout.CENTER);

    addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            setVisible(false);
          }
        });

    p.add(buildToolBar(), BorderLayout.NORTH);
    help.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
        .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "Close");
    help.getActionMap()
        .put(
            "Close",
            new AbstractAction() {
              public void actionPerformed(ActionEvent e) {
                setVisible(false);
              }
            });

    setMinimumSize(new Dimension(400, 200));
    setTitle(tr("JOSM Help Browser"));
  }
  protected void build() {
    jepMessage = new JEditorPane("text/html", "");
    jepMessage.setOpaque(false);
    jepMessage.setEditable(false);
    jepMessage.addHyperlinkListener(this);
    Font f = UIManager.getFont("Label.font");
    StyleSheet ss = new StyleSheet();
    String rule =
        MessageFormat.format(
            "font-family: ''{0}'';font-size: {1,number}pt; font-weight: {2}; font-style: {3}",
            f.getName(),
            f.getSize(),
            f.isBold() ? "bold" : "normal",
            f.isItalic() ? "italic" : "normal");
    rule = "body {" + rule + "}";
    rule =
        MessageFormat.format(
            "font-family: ''{0}'';font-size: {1,number}pt; font-weight: {2}; font-style: {3}",
            f.getName(), f.getSize(), "bold", f.isItalic() ? "italic" : "normal");
    rule = "strong {" + rule + "}";
    ss.addRule(rule);
    ss.addRule("a {text-decoration: underline; color: blue}");
    HTMLEditorKit kit = new HTMLEditorKit();
    kit.setStyleSheet(ss);
    jepMessage.setEditorKit(kit);

    setLayout(new BorderLayout());
    add(jepMessage, BorderLayout.CENTER);
    lblWarning = new JLabel("");
    lblWarning.setVisible(false);
    lblWarning.setIcon(ImageProvider.get("warning-small.png"));
    lblWarning.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    JPanel pnl = new JPanel(new BorderLayout());
    pnl.add(lblWarning, BorderLayout.NORTH);
    add(pnl, BorderLayout.WEST);
  }