Example usage for javax.swing.text JTextComponent equals

List of usage examples for javax.swing.text JTextComponent equals

Introduction

In this page you can find the example usage for javax.swing.text JTextComponent equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:DragColorTextFieldDemo.java

public boolean importData(JComponent c, Transferable t) {
    JTextComponent tc = (JTextComponent) c;

    if (!canImport(c, t.getTransferDataFlavors())) {
        return false;
    }/*ww w.  jav a  2  s.c om*/

    if (tc.equals(source) && (tc.getCaretPosition() >= p0.getOffset())
            && (tc.getCaretPosition() <= p1.getOffset())) {
        shouldRemove = false;
        return true;
    }

    if (hasStringFlavor(t.getTransferDataFlavors())) {
        try {
            String str = (String) t.getTransferData(stringFlavor);
            tc.replaceSelection(str);
            return true;
        } catch (UnsupportedFlavorException ufe) {
            System.out.println("importData: unsupported data flavor");
        } catch (IOException ioe) {
            System.out.println("importData: I/O exception");
        }
    }
    //The ColorTransferHandler superclass handles color.
    return super.importData(c, t);
}