示例#1
0
  /** Displays the Spark error log. */
  private void showErrorLog() {
    final File logDir = new File(Spark.getLogDirectory(), "errors.log");

    // Read file and show
    final String errorLogs = URLFileSystem.getContents(logDir);

    final JFrame frame = new JFrame(Res.getString("title.client.logs"));
    frame.setLayout(new BorderLayout());
    frame.setIconImage(SparkManager.getApplicationImage().getImage());

    final JTextPane pane = new JTextPane();
    pane.setBackground(Color.white);
    pane.setFont(new Font("Dialog", Font.PLAIN, 12));
    pane.setEditable(false);
    pane.setText(errorLogs);

    frame.add(new JScrollPane(pane), BorderLayout.CENTER);

    final JButton copyButton = new JButton(Res.getString("button.copy.to.clipboard"));
    frame.add(copyButton, BorderLayout.SOUTH);

    copyButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            SparkManager.setClipboard(errorLogs);
            copyButton.setEnabled(false);
          }
        });

    frame.pack();
    frame.setSize(600, 400);

    GraphicUtils.centerWindowOnScreen(frame);
    frame.setVisible(true);
  }