Discord Server Twitter
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tutorial Java Copy a Text
#1
Tongue 
In The Name OF Allah
Al-Salam Alekum

Hi guys, in Java Swing we don't have a direct method for copying a text as we have in JavaFX so we will use this method today to copy a text from (TextArea, TextField). Big Grin


Code:
String get = textArea1.getText() ; //getting a text
StringSelection selection = new StringSelection(get); //selecting all to the text
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); //Define a clipboard
clipboard.setContents(selection, selection); //copy the text ;)
Heart
Wa Salam Alekum

[Image: 0yaXvcy.gif]
We Are Anonymous, We Are Legion, We Do not Forgive, We do not Forget
Expect Us
Reply




Users browsing this thread: 1 Guest(s)