-1

Sirs,

I am writing a short GUI based program in Java using the NetBeans IDE. The overall agenda of the program is to create a long string of automatically generated text that appears in a text box (JTextPane, to be exact). The text generated will be cut and pasted by the user into another application.

One of the features that I would like to add to my application is a button that says "Copy text to clipboard" and does exactly that. As my application stands, the user has to copy and paste the text for themselves.

Can anyone get me started on what event/object methods/properties to use to create such functionality in a button? It would be perfectly acceptable to just point me in the right direction -- I'm not expecting a comprehensive answer. However, I would appreciate a response more specific that "consult the NetBeans manual". I can already write basic and intermediate GUI applications and I am well aware of the existence of documentation. None of the other questions that I have searched for on this site seem to address this issue directly -- unless I have missed something altogether.

I would copy and paste the source code to my program, but it is well over 2000 lines long, and I'm not sure it is necessary anyway. I would be happy to provide any additional info about my application if it is needed. I guess my biggest problem is that I'm not even sure of what keywords I need to even begin such a search.

Thank you in advance,

the_photon

the_photon
  • 196
  • 2
  • 10
  • 1
    [JTextArea#copy](http://docs.oracle.com/javase/7/docs/api/javax/swing/text/JTextComponent.html#copy()), [JTextArea#cut](http://docs.oracle.com/javase/7/docs/api/javax/swing/text/JTextComponent.html#cut()), [JTextArea#paste](http://docs.oracle.com/javase/7/docs/api/javax/swing/text/JTextComponent.html#paste()) – MadProgrammer Dec 31 '14 at 01:38
  • 1
    You could also use the JTextArea's key binding actions directly, see [this example](http://stackoverflow.com/questions/27261759/need-help-implementing-mouselistener-in-jtextarea/27261833#27261833) zero more details – MadProgrammer Dec 31 '14 at 01:41
  • Thank you, MadProgrammer. I'll look in to these tomorrow -- this should give me enough of a foundation to find what I need. – the_photon Dec 31 '14 at 02:00

1 Answers1

0

You could create a derby server database and update the value in the database anytime the person clicks the button to copy to clipboard. When the person goes to paste into the other application just have a button ready to click and get the value that was placed into the database by the other application.

Just be sure to remove any old data in the clipboard (database) whenever you place new data into it. Hope this may help you. If not let me know.