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

📄 openswingutil.java

📁 OpenSwing的经典示例
💻 JAVA
字号:
package com.sunking.swing;

import java.awt.*;
import javax.swing.*;
import java.io.*;
import java.util.*;

/**
 * <p>Title: OpenSwing</p>
 * <p>Description: OpenSwingUtil 工具类</p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: </p>
 * @author <a href="mailto:sunkingxie@hotmail.com">SunKing</a>
 * @version 1.0
 */
public final class OpenSwingUtil
    implements Serializable {
    private static ResourceBundle rb;
    public static ImageIcon getOpenSwingImage(String name) {
        return getOpenSwingImage(name, null);
    }
    /**
     * 取得图象资源
     * @param name String 图像名
     * @param defaultIcon ImageIcon 未取到时赋予的默认图像
     * @return ImageIcon
     */
    public static ImageIcon getOpenSwingImage(String name,
                                              ImageIcon defaultIcon) {
        ImageIcon icon = null;
        try {
            java.net.URL url = new java.net.URL(
                "jar:file:" + (new File("OpenSwing.jar").
                               getAbsolutePath().replace(File.separatorChar,
                '/')) + "!/image/" + name);
            icon = new ImageIcon(url);
        }
        catch (Exception ex) {
        }
        if (icon == null || icon.getImageLoadStatus() != MediaTracker.COMPLETE) {
            icon = new ImageIcon("image/" + name);
        }
        if (icon == null || icon.getImageLoadStatus() != MediaTracker.COMPLETE) {
            icon = defaultIcon;
        }
        return icon;
    }
    /**
     * 取得国际化文字资源
     * @param key String  关键字
     * @return String
     */
    public static String getOpenResource(String key) {
        if (rb == null) {
            try {
                rb = ResourceBundle.getBundle("OpenSwing",
                                              Locale.getDefault(),
                                              ClassLoader.
                                              getSystemClassLoader());
            }
            catch (Exception ex) {
                throw new NullPointerException(
                    "ERROR:CAN NOT FOUND RESOURCE FILE!  " +
                    new File("OpenSwing" + Locale.getDefault().toString() +
                             ".properties").getAbsolutePath());
            }
        }
        return rb.getString(key);
    }
}

⌨️ 快捷键说明

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