## modules/graphics/src/main/java/javafx/scene/Cursor.java

Print this page

    rev 4839 : RT-2529: Locale specific runtime errors (Turkish)

      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
      23  * questions.
      24  */
      25
      26 package javafx.scene;
      27
      28 import java.net.MalformedURLException;
      29 import java.net.URL;

      30 import javafx.scene.image.Image;
      31 import com.sun.javafx.cursor.CursorFrame;
      32 import com.sun.javafx.cursor.CursorType;
      33 import com.sun.javafx.cursor.StandardCursorFrame;
      34
      35 /**
      36  * A class to encapsulate the bitmap representation of the mouse cursor.
      37  * @since JavaFX 2.0
      38  */
      39 public abstract class Cursor {
      40     /**
      41      * The default cursor type (gets set if no cursor is defined).
      42      */
      43     public static final Cursor DEFAULT =
      44             new StandardCursor("DEFAULT", CursorType.DEFAULT);
      45
      46     /**
      47      * The crosshair cursor type.
      48      */
      49     public static final Cursor CROSSHAIR =
     202      * either a name of some standard cursor or a valid URL string. If the
     203      * identifier names a standard cursor the corresponding cursor is returned.
     204      * In the case of a URL string, the method returns a new {@code ImageCursor}
     205      * created for that URL.
     206      *
     207      * @param identifier the cursor identifier
     208      * @return the cursor for the identifier
     209      * @throws IllegalArgumentException if the cursor identifier is not a
     210      *      valid URL string nor any standard cursor name
     211      */
     212     public static Cursor cursor(final String identifier) {
     213         if (identifier == null) {
     214             throw new NullPointerException(
     215                     "The cursor identifier must not be null");
     216         }
     217
     218         if (isUrl(identifier)) {
     219             return new ImageCursor(new Image(identifier));
     220         }
     221
     222         String uName = identifier.toUpperCase();
     223         if (uName.equals(DEFAULT.name)) {
     224             return DEFAULT;
     225         } else if(uName.equals(CROSSHAIR.name)) {
     226             return CROSSHAIR;
     227         } else if (uName.equals(TEXT.name)) {
     228             return TEXT;
     229         } else if (uName.equals(WAIT.name)) {
     230             return WAIT;
     231         } else if (uName.equals(MOVE.name)) {
     232             return MOVE;
     233         } else if (uName.equals(SW_RESIZE.name)) {
     234             return SW_RESIZE;
     235         } else if (uName.equals(SE_RESIZE.name)) {
     236             return SE_RESIZE;
     237         } else if (uName.equals(NW_RESIZE.name)) {
     238             return NW_RESIZE;
     239         } else if (uName.equals(NE_RESIZE.name)) {
     240             return NE_RESIZE;
     241         } else if (uName.equals(N_RESIZE.name)) {
     242             return N_RESIZE;
      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
      23  * questions.
      24  */
      25
      26 package javafx.scene;
      27
      28 import java.net.MalformedURLException;
      29 import java.net.URL;
      30 import java.util.Locale;
      31 import javafx.scene.image.Image;
      32 import com.sun.javafx.cursor.CursorFrame;
      33 import com.sun.javafx.cursor.CursorType;
      34 import com.sun.javafx.cursor.StandardCursorFrame;
      35
      36 /**
      37  * A class to encapsulate the bitmap representation of the mouse cursor.
      38  * @since JavaFX 2.0
      39  */
      40 public abstract class Cursor {
      41     /**
      42      * The default cursor type (gets set if no cursor is defined).
      43      */
      44     public static final Cursor DEFAULT =
      45             new StandardCursor("DEFAULT", CursorType.DEFAULT);
      46
      47     /**
      48      * The crosshair cursor type.
      49      */
      50     public static final Cursor CROSSHAIR =
     203      * either a name of some standard cursor or a valid URL string. If the
     204      * identifier names a standard cursor the corresponding cursor is returned.
     205      * In the case of a URL string, the method returns a new {@code ImageCursor}
     206      * created for that URL.
     207      *
     208      * @param identifier the cursor identifier
     209      * @return the cursor for the identifier
     210      * @throws IllegalArgumentException if the cursor identifier is not a
     211      *      valid URL string nor any standard cursor name
     212      */
     213     public static Cursor cursor(final String identifier) {
     214         if (identifier == null) {
     215             throw new NullPointerException(
     216                     "The cursor identifier must not be null");
     217         }
     218
     219         if (isUrl(identifier)) {
     220             return new ImageCursor(new Image(identifier));
     221         }
     222
     223         String uName = identifier.toUpperCase(Locale.ROOT);
     224         if (uName.equals(DEFAULT.name)) {
     225             return DEFAULT;
     226         } else if(uName.equals(CROSSHAIR.name)) {
     227             return CROSSHAIR;
     228         } else if (uName.equals(TEXT.name)) {
     229             return TEXT;
     230         } else if (uName.equals(WAIT.name)) {
     231             return WAIT;
     232         } else if (uName.equals(MOVE.name)) {
     233             return MOVE;
     234         } else if (uName.equals(SW_RESIZE.name)) {
     235             return SW_RESIZE;
     236         } else if (uName.equals(SE_RESIZE.name)) {
     237             return SE_RESIZE;
     238         } else if (uName.equals(NW_RESIZE.name)) {
     239             return NW_RESIZE;
     240         } else if (uName.equals(NE_RESIZE.name)) {
     241             return NE_RESIZE;
     242         } else if (uName.equals(N_RESIZE.name)) {
     243             return N_RESIZE;