< prev index next >

src/java.desktop/share/classes/javax/swing/text/DefaultCaret.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 808     /**
 809      * Returns an array of all the objects currently registered
 810      * as <code><em>Foo</em>Listener</code>s
 811      * upon this caret.
 812      * <code><em>Foo</em>Listener</code>s are registered using the
 813      * <code>add<em>Foo</em>Listener</code> method.
 814      *
 815      * <p>
 816      *
 817      * You can specify the <code>listenerType</code> argument
 818      * with a class literal,
 819      * such as
 820      * <code><em>Foo</em>Listener.class</code>.
 821      * For example, you can query a
 822      * <code>DefaultCaret</code> <code>c</code>
 823      * for its change listeners with the following code:
 824      *
 825      * <pre>ChangeListener[] cls = (ChangeListener[])(c.getListeners(ChangeListener.class));</pre>
 826      *
 827      * If no such listeners exist, this method returns an empty array.
 828      *
 829      * @param listenerType the type of listeners requested; this parameter
 830      *          should specify an interface that descends from
 831      *          <code>java.util.EventListener</code>
 832      * @return an array of all objects registered as
 833      *          <code><em>Foo</em>Listener</code>s on this component,
 834      *          or an empty array if no such
 835      *          listeners have been added
 836      * @exception ClassCastException if <code>listenerType</code>
 837      *          doesn't specify a class or interface that implements
 838      *          <code>java.util.EventListener</code>
 839      *
 840      * @see #getChangeListeners
 841      *
 842      * @since 1.3
 843      */
 844     public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
 845         return listenerList.getListeners(listenerType);
 846     }
 847 
 848     /**
 849      * Changes the selection visibility.
 850      *
 851      * @param vis the new visibility


   1 /*
   2  * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 808     /**
 809      * Returns an array of all the objects currently registered
 810      * as <code><em>Foo</em>Listener</code>s
 811      * upon this caret.
 812      * <code><em>Foo</em>Listener</code>s are registered using the
 813      * <code>add<em>Foo</em>Listener</code> method.
 814      *
 815      * <p>
 816      *
 817      * You can specify the <code>listenerType</code> argument
 818      * with a class literal,
 819      * such as
 820      * <code><em>Foo</em>Listener.class</code>.
 821      * For example, you can query a
 822      * <code>DefaultCaret</code> <code>c</code>
 823      * for its change listeners with the following code:
 824      *
 825      * <pre>ChangeListener[] cls = (ChangeListener[])(c.getListeners(ChangeListener.class));</pre>
 826      *
 827      * If no such listeners exist, this method returns an empty array.
 828      * @param <T> the listener type
 829      * @param listenerType the type of listeners requested


 830      * @return an array of all objects registered as
 831      *          <code><em>Foo</em>Listener</code>s on this component,
 832      *          or an empty array if no such
 833      *          listeners have been added
 834      * @exception ClassCastException if <code>listenerType</code>
 835      *          doesn't specify a class or interface that implements
 836      *          <code>java.util.EventListener</code>
 837      *
 838      * @see #getChangeListeners
 839      *
 840      * @since 1.3
 841      */
 842     public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
 843         return listenerList.getListeners(listenerType);
 844     }
 845 
 846     /**
 847      * Changes the selection visibility.
 848      *
 849      * @param vis the new visibility


< prev index next >