Results 1 to 3 of 3

Thread: Copy text to clipboard using JAVA

  1. #1
    BakerJones is offline Senior Member
    Join Date
    Dec 2009
    Posts
    244
    Rep Power
    3

    Default Copy text to clipboard using JAVA

    I want to copy string variable which has text on to clipboard. I tried many things but didn’t solve my problem. So please provide me some ideas or suggestions to solve this problem. Any help will be appreciated.

  2. #2
    AdamsClark is offline Senior Member
    Join Date
    Dec 2009
    Posts
    247
    Rep Power
    3

    Default

    To copy string to clipboard uses the code given below:


    String mg = "pouet";
    StringSelection sers = new StringSelection(mg);
    Toolkit.getDefaultToolkit().getSystemClipboard().s etContent(sers null);

  3. #3
    TorresScott is offline Senior Member
    Join Date
    Dec 2009
    Posts
    239
    Rep Power
    3

    Default

    try the code given below, this may helpful to solve your problem.

    String str = jt.getSelectedText();
    StringSelection strsel = new StringSelection(str);
    Clipboard clbrd =
    Toolkit.getDefaultToolkit().getSystemClipboard();
    clbrd.setContents(strsel, strsel);

Similar Threads

  1. Opening and editing text file in java
    By WilsonMartin in forum Programming
    Replies: 2
    Last Post: 03-30-2010, 01:02 PM
  2. Open and write text file in JAVA
    By Davismoore in forum Programming
    Replies: 2
    Last Post: 03-26-2010, 02:50 PM
  3. Keep Multiple Text Items on Your Clipboard
    By alfie57 in forum Software Jargons
    Replies: 0
    Last Post: 12-03-2009, 02:51 PM
  4. Turbo-charge the Windows Clipboard
    By tiank89 in forum Applications
    Replies: 0
    Last Post: 10-17-2008, 10:08 AM
  5. innovative clipboard management
    By gemon2 in forum Windows XP
    Replies: 0
    Last Post: 04-14-2008, 09:32 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
SEO by SubmitEdge

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48