Copy error messages to clipboard on click

This commit is contained in:
Reinhard Pointner 2016-09-26 16:15:37 +08:00
parent 61e78ec16b
commit 4b44495782
1 changed files with 8 additions and 4 deletions

View File

@ -4,11 +4,15 @@
package net.filebot.util.ui.notification;
import static net.filebot.util.ui.SwingUI.*;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.Window;
import java.awt.datatransfer.StringSelection;
import javax.swing.BorderFactory;
import javax.swing.Icon;
@ -19,14 +23,12 @@ import javax.swing.JTextPane;
import javax.swing.SwingConstants;
import javax.swing.border.Border;
public class MessageNotification extends NotificationWindow {
public MessageNotification(String head, String text, Icon icon, int timeout) {
this((Window) null, head, text, icon, timeout);
}
public MessageNotification(String head, String text, Icon icon) {
this(head, text, icon, -1);
}
@ -39,7 +41,6 @@ public class MessageNotification extends NotificationWindow {
private JTextPane textArea;
private JLabel imageLabel;
public MessageNotification(Window owner, String head, String text, Icon icon, int timeout) {
super(owner, timeout);
@ -70,8 +71,11 @@ public class MessageNotification extends NotificationWindow {
}
c.add(textPanel, BorderLayout.CENTER);
pack();
// copy message to clipboard
getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
getGlassPane().addMouseListener(mouseClicked(evt -> Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(text), null)));
}
}