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

📄 openswingutil.java

📁 几个开源的SWING界面的接口
💻 JAVA
字号:
package com.sunking.swing;

import java.io.*;
import java.util.*;

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

/**
 * <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 = ClassLoader.getSystemResource(
                "com/sunking/swing/images/" + name);
            icon = new ImageIcon(url);
        }
        catch (Exception ex) {
        }
        if (icon == null
            || icon.getImageLoadStatus() != MediaTracker.COMPLETE
            || icon.getIconHeight() <= 0) {
            icon = defaultIcon;
        }
        return icon;
    }
    /**
     * 取得国际化文字资源
     * @param key String  关键字
     * @return String
     */
    public static String getOpenResource(String key) {
        if (rb == null) {
            try{
                rb = ResourceBundle.getBundle(
                    "com.sunking.swing.properties.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);
    }

    public static JFrame createDemoFrame(String title){
        JFrame frame = new JFrame(title);
        frame.setSize(400, 320);
        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
        frame.setLocation((d.width - frame.getSize().width) / 2,
                          (d.height - frame.getSize().height) / 2);
        return frame;
    }
}

⌨️ 快捷键说明

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