public String getClipboardText() throws Exception {
		Clipboard c = GClipboard.getSystemClipboard();
		Transferable t = c.getContents(null);

		try {
			String text = (String) t.getTransferData(DataFlavor.stringFlavor);
			return text;
		}
		catch (UnsupportedFlavorException e) {
			Msg.error(this, "Unsupported data flavor - 'string'.  Supported flavors: ");
			DataFlavor[] flavors = t.getTransferDataFlavors();
			for (DataFlavor dataFlavor : flavors) {
				Msg.error(this, "\t" + dataFlavor.getHumanPresentableName());
			}
			throw e;
		}
	}
Gets any current text on the clipboard

@return the text on the clipboard; null if no text is on the clipboard
@throws Exception if there are any issues copying from the clipboard
Ghidra/Framework/Docking/src/main/java/docking/test/AbstractDockingTest.java