gui
Class JTextComponentToClipboardCopier

java.lang.Object
  extended by gui.JTextComponentToClipboardCopier

public class JTextComponentToClipboardCopier
extends java.lang.Object

Adds a context menu to JTextComponents that is activated by a click on the right mouse button that enabled the user to copy the text to clipboard.

Author:
Rolf Wendolsky

Field Summary
private  javax.swing.text.JTextComponent m_currentPopup
           
private  javax.swing.JPopupMenu m_popup
           
private  java.awt.event.MouseAdapter m_popupListener
           
private static java.lang.String MSG_COPY_SELECTED_TO_CLIP
           
private static java.lang.String MSG_COPY_TO_CLIP
           
 
Constructor Summary
JTextComponentToClipboardCopier(boolean a_bCopySelectedTextOnly)
          Constructor.
 
Method Summary
 void registerTextComponent(javax.swing.text.JTextComponent a_textComponent)
          Adds a popup menu for copying the text to this text component.
 void unregisterTextComponent(javax.swing.text.JTextComponent a_textComponent)
          Removes a previously registered popup menu from this text component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MSG_COPY_TO_CLIP

private static final java.lang.String MSG_COPY_TO_CLIP

MSG_COPY_SELECTED_TO_CLIP

private static final java.lang.String MSG_COPY_SELECTED_TO_CLIP

m_popup

private javax.swing.JPopupMenu m_popup

m_currentPopup

private javax.swing.text.JTextComponent m_currentPopup

m_popupListener

private java.awt.event.MouseAdapter m_popupListener
Constructor Detail

JTextComponentToClipboardCopier

public JTextComponentToClipboardCopier(boolean a_bCopySelectedTextOnly)
Constructor.

Parameters:
a_bCopySelectedTextOnly - if only the selected text should be copied to clipboard; otherwise, the complete text from the component is copied.
Method Detail

registerTextComponent

public void registerTextComponent(javax.swing.text.JTextComponent a_textComponent)
Adds a popup menu for copying the text to this text component.

Parameters:
a_textComponent - a JTextComponent

unregisterTextComponent

public void unregisterTextComponent(javax.swing.text.JTextComponent a_textComponent)
Removes a previously registered popup menu from this text component.

Parameters:
a_textComponent - a JTextComponent