⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resources.java

📁 tiled地图编辑器是2d的,很不错的国外软件,使用起来很方便的
💻 JAVA
字号:
/* *  Tiled Map Editor, (c) 2004-2006 * *  This program is free software; you can redistribute it and/or modify *  it under the terms of the GNU General Public License as published by *  the Free Software Foundation; either version 2 of the License, or *  (at your option) any later version. * *  Adam Turk <aturk@biggeruniverse.com> *  Bjorn Lindeijer <b.lindeijer@xs4all.nl> */package tiled.mapeditor;import java.util.ResourceBundle;import java.awt.Image;import java.io.IOException;import javax.imageio.ImageIO;import javax.swing.Icon;import javax.swing.ImageIcon;/** * This class implements static accessors to common editor resources. These * currently include icons and internationalized strings. * * @version $Id: Resources.java 683 2006-06-25 14:17:37Z bjorn $ */public final class Resources {    // The resource bundle used by this class    private static final ResourceBundle resourceBundle =            ResourceBundle.getBundle(                    Resources.class.getPackage().getName() + ".resources.gui");    // Prevent instanciation    private Resources() {    }    /**     * Retrieves a string from the resource bundle in the default locale.     *     * @param key the key for the desired string     * @return the string for the given key     */    public static String getString(String key) {        return resourceBundle.getString(key);    }    /**     * Loads an image from the resources directory. This directory is part of     * the distribution jar.     *     * @param filename the filename relative from the resources directory     * @return A BufferedImage instance of the image     * @throws IOException if an error occurs during reading     * @throws IllegalArgumentException when the resource could not be found     */    private static Image getImage(String filename) throws IOException,            IllegalArgumentException {        return ImageIO.read(Resources.class.getResourceAsStream(                "resources/" + filename));    }    /**     * Loads the image using {@link #getImage(String)} and uses it to create     * a new {@link ImageIcon} instance.     *     * @param filename the filename of the image relative from the     *                 <code>resources</code> directory     * @return the loaded icon, or <code>null</code> when an error occured     *         while loading the image     */    public static Icon getIcon(String filename) {        try {            return new ImageIcon(getImage(filename));        } catch (IOException e) {            System.out.println("Failed to load as image: " + filename);        } catch (IllegalArgumentException e) {            System.out.println("Failed to load resource: " + filename);        }        return null;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -