Example usage for javax.swing JTextPane setTransferHandler

List of usage examples for javax.swing JTextPane setTransferHandler

Introduction

In this page you can find the example usage for javax.swing JTextPane setTransferHandler.

Prototype

@BeanProperty(hidden = true, description = "Mechanism for transfer of data to and from the component")
public void setTransferHandler(TransferHandler newHandler) 

Source Link

Document

Sets the TransferHandler , which provides support for transfer of data into and out of this component via cut/copy/paste and drag and drop.

Usage

From source file:org.languagetool.gui.ResultArea.java

ResultArea(final ResourceBundle messages, final LanguageToolSupport ltSupport, final JTextPane statusPane) {
    this.messages = messages;
    this.ltSupport = ltSupport;
    this.statusPane = statusPane;
    statusPane.setContentType("text/html");
    statusPane.setText(Main.HTML_GREY_FONT_START + messages.getString("resultAreaText") + Main.HTML_FONT_END);
    statusPane.setEditable(false);//  w  w  w . j a va  2 s  .c o m
    statusPane.addHyperlinkListener(new MyHyperlinkListener());
    statusPane.setTransferHandler(new RetainLineBreakTransferHandler());
    ltSupport.addLanguageToolListener(new LanguageToolListener() {
        @Override
        public void languageToolEventOccurred(LanguageToolEvent event) {
            if (event.getType() == LanguageToolEvent.Type.CHECKING_STARTED) {
                final Language lang = ltSupport.getLanguage();
                final String langName;
                if (lang.isExternal()) {
                    langName = lang.getTranslatedName(messages) + Main.EXTERNAL_LANGUAGE_SUFFIX;
                } else {
                    langName = lang.getTranslatedName(messages);
                }
                final String startCheckText = Main.HTML_GREY_FONT_START
                        + Tools.makeTexti18n(messages, "startChecking", langName) + "..." + Main.HTML_FONT_END;
                statusPane.setText(startCheckText);
                setStartText(startCheckText);
                if (event.getCaller() == marker) {
                    statusPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                }
            } else if (event.getType() == LanguageToolEvent.Type.CHECKING_FINISHED) {
                inputText = event.getSource().getTextComponent().getText();
                setRuleMatches(event.getSource().getMatches());
                if (event.getCaller() == marker || event.getCaller() == null) {
                    displayResult();
                    if (event.getCaller() == marker) {
                        statusPane.setCursor(Cursor.getDefaultCursor());
                    }
                }
            } else if (event.getType() == LanguageToolEvent.Type.RULE_DISABLED
                    || event.getType() == LanguageToolEvent.Type.RULE_ENABLED) {
                inputText = event.getSource().getTextComponent().getText();
                setRuleMatches(event.getSource().getMatches());
                displayResult();
            }
        }
    });
}

From source file:org.languagetool.gui.ResultAreaHelper.java

private ResultAreaHelper(ResourceBundle messages, LanguageToolSupport ltSupport, JTextPane statusPane) {
    this.messages = messages;
    this.ltSupport = ltSupport;
    this.statusPane = statusPane;
    statusPane.setContentType("text/html");
    statusPane.setEditable(false);/*  www.  j a v  a2 s  . c  o  m*/
    statusPane.setTransferHandler(new RetainLineBreakTransferHandler());
    enable();
}