SwingUI.copyToClipboard(String text)
This commit is contained in:
parent
8b3e2825be
commit
e3fbd3825f
|
@ -16,9 +16,7 @@ import static net.filebot.util.ui.SwingUI.*;
|
|||
import java.awt.Component;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.Window;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.io.File;
|
||||
|
@ -364,7 +362,7 @@ public class RenamePanel extends JComponent {
|
|||
installAction(this, WHEN_IN_FOCUSED_WINDOW, getKeyStroke(VK_F7, 0), newAction("Copy Debug Information", evt -> {
|
||||
try {
|
||||
withWaitCursor(evt.getSource(), () -> {
|
||||
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(getDebugInfo()), null);
|
||||
copyToClipboard(getDebugInfo());
|
||||
log.info("Match model has been copied to clipboard");
|
||||
});
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -13,7 +13,9 @@ import java.awt.Frame;
|
|||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.Window;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.dnd.DnDConstants;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.InputEvent;
|
||||
|
@ -62,6 +64,10 @@ public final class SwingUI {
|
|||
}
|
||||
}
|
||||
|
||||
public static void copyToClipboard(String text) {
|
||||
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(text), null);
|
||||
}
|
||||
|
||||
public static void checkEventDispatchThread() {
|
||||
if (!SwingUtilities.isEventDispatchThread()) {
|
||||
throw new IllegalStateException("Method must be accessed from the Swing Event Dispatch Thread, but was called on Thread \"" + Thread.currentThread().getName() + "\"");
|
||||
|
|
|
@ -10,9 +10,7 @@ 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;
|
||||
|
@ -75,7 +73,7 @@ public class MessageNotification extends NotificationWindow {
|
|||
|
||||
// copy message to clipboard
|
||||
getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
getGlassPane().addMouseListener(mouseClicked(evt -> Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(text), null)));
|
||||
getGlassPane().addMouseListener(mouseClicked(evt -> copyToClipboard(text)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue