Java JOptionPane Message copyToClipBoard(String code, boolean displayMessage)

Here you can find the source of copyToClipBoard(String code, boolean displayMessage)

Description

copy To Clip Board

License

Apache License

Declaration

public static void copyToClipBoard(String code, boolean displayMessage) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import javax.swing.JOptionPane;

public class Main {
    /***********************************************************************/
    public static void copyToClipBoard(String code) {
        copyToClipBoard(code, true);/*from   w w w .  j  a v a 2  s  . c  om*/
    }

    public static void copyToClipBoard(String code, boolean displayMessage) {
        java.awt.datatransfer.StringSelection selection = new java.awt.datatransfer.StringSelection(code);
        java.awt.Frame frame = new java.awt.Frame();
        frame.getToolkit().getSystemClipboard().setContents(selection, selection);
        if (displayMessage) {
            JOptionPane.showMessageDialog(null, "Code copied to Clipboard", "Finished",
                    JOptionPane.INFORMATION_MESSAGE);
        }
        frame.dispose();
    }
}

Related

  1. askPassword(String message)
  2. browse(String url, Component msgParent)
  3. browse(String url, Component msgParent)
  4. chooseIndex(String message, String messageTitle, Object[] objects, Object initialObject)
  5. chooseObject(String message, String messageTitle, Object[] objects, Object initialObject)
  6. createPane(Component comp, String msg)
  7. createPane(int type, String message, int messageMaxLength)
  8. debug(String message)
  9. display2(Component parent, String message, String title, int optionType, int messageType, Icon icon)