Example usage for java.awt.datatransfer Clipboard addFlavorListener

List of usage examples for java.awt.datatransfer Clipboard addFlavorListener

Introduction

In this page you can find the example usage for java.awt.datatransfer Clipboard addFlavorListener.

Prototype

public synchronized void addFlavorListener(FlavorListener listener) 

Source Link

Document

Registers the specified FlavorListener to receive FlavorEvent s from this clipboard.

Usage

From source file:org.docx4all.ui.main.WordMLEditor.java

void preStartup(JApplet applet) {
    _applet = applet;//w w  w. ja va 2s .co  m

    _viewManager = new ViewManager();

    _iframeMap = new HashMap<String, JInternalFrame>();

    log.info("setting up InternalFrameListener");
    _internalFrameListener = new InternalFrameListener();

    log.info("setting up TitleBarMouseListener");
    _titleBarMouseListener = new TitleBarMouseListener();

    log.info("setting up ToolBarStates");
    _toolbarStates = new ToolBarStates();
    Clipboard clipboard = getContext().getClipboard();
    clipboard.addFlavorListener(_toolbarStates);
    //As a FlavorListener, _toolbarStates will ONLY be notified
    //when there is a DataFlavor change in Clipboard. 
    //Therefore, make sure that toolbarStates' _isPasteEnable property 
    //is initialised correctly.
    boolean available = clipboard.isDataFlavorAvailable(WordMLTransferable.STRING_FLAVOR)
            || clipboard.isDataFlavorAvailable(WordMLTransferable.WORDML_FRAGMENT_FLAVOR);
    _toolbarStates.setPasteEnabled(available);

    log.info("setting up VFSJFileChooser");
    initVFSJFileChooser();

    log.info("setting up WmlExitListener");
    addExitListener(new WmlExitListener());
}