/** 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); }
/** * Constructs the UI for the MainWindow. The MainWindow UI is the container for the entire Spark * application. * * @param title the title of the frame. * @param icon the icon used in the frame. */ private MainWindow(String title, ImageIcon icon) { // Initialize and dock the menus buildMenu(); // Add Workspace Container getContentPane().setLayout(new BorderLayout()); LayoutSettings settings = LayoutSettingsManager.getLayoutSettings(); if (settings.getMainWindowX() == 0 && settings.getMainWindowY() == 0) { // Use default settings. setSize(300, 500); GraphicUtils.centerWindowOnScreen(this); } else { setBounds( settings.getMainWindowX(), settings.getMainWindowY(), settings.getMainWindowWidth(), settings.getMainWindowHeight()); } // Add menubar this.setJMenuBar(mainWindowBar); this.getContentPane().add(topToolbar, BorderLayout.NORTH); setTitle(title); setIconImage(icon.getImage()); // Setup WindowListener to be the proxy to the actual window listener // which cannot normally be used outside of the Window component because // of protected access. addWindowListener( new WindowAdapter() { /** * This event fires when the window has become active. * * @param e WindowEvent is not used. */ public void windowActivated(WindowEvent e) { fireWindowActivated(); } /** Invoked when a window is de-activated. */ public void windowDeactivated(WindowEvent e) {} /** * This event fires whenever a user minimizes the window from the toolbar. * * @param e WindowEvent is not used. */ public void windowIconified(WindowEvent e) {} /** * This event fires when the application is closing. This allows Plugins to do any * persistence or other work before exiting. * * @param e WindowEvent is never used. */ public void windowClosing(WindowEvent e) { saveLayout(); setVisible(false); } }); this.addWindowFocusListener(new MainWindowFocusListener()); }