• Java基础知识:Java实现Map集合二级联动3


    * Returns an image stored in the file at the specified path

      * @param path String The path to the image file

      * @return Image The image stored in the file at the specified path

      */

      public static Image getImage(String path) {

      return getImage("default", path); //$NON-NLS-1$

      }

      /**

      * Returns an image stored in the file at the specified path

      * @param section String The storage section in the cache

      * @param path String The path to the image file

      * @return Image The image stored in the file at the specified path

      */

      public static Image getImage(String section, String path) {

      String key = section + '|' + SwingResourceManager.class.getName() + '|' + path;

      Image image = m_ClassImageMap.get(key);

      if (image == null) {

      try {

      FileInputStream fis = new FileInputStream(path);

      image = getImage(fis);

      m_ClassImageMap.put(key, image);

      fis.close();

      } catch (IOException e) {

      return null;

      }

      }

      return image;

      }

      /**

      * Clear cached images in specified section

      * @param section the section do clear

      */

      public static void clearImages(String section) {

      for (Iterator I = m_ClassImageMap.keySet().iterator(); I.hasNext();) {

      String key = I.next();

      if (!key.startsWith(section + '|'))

      continue;

      Image image = m_ClassImageMap.get(key);

      image.flush();

      I.remove();

      }

      }

      /**

      * Returns an icon stored in the file at the specified path relative to the specified class

      * @param clazz Class The class relative to which to find the icon

      * @param path String The path to the icon file

      * @return Icon The icon stored in the file at the specified path

      */

      public static ImageIcon getIcon(Class clazz, String path) {

      return getIcon(getImage(clazz, path));

      }

      /**

      * Returns an icon stored in the file at the specified path

      * @param path String The path to the icon file

      * @return Icon The icon stored in the file at the specified path

      */

      public static ImageIcon getIcon(String path) {

      return getIcon("default", path); //$NON-NLS-1$

      }

      /**

      * Returns an icon stored in the file at the specified path

      * @param section String The storage section in the cache

      * @param path String The path to the icon file

      * @return Icon The icon stored in the file at the specified path

      */

      public static ImageIcon getIcon(String section, String path) {

      return getIcon(getImage(section, path));

      }

      /**

      * Returns an icon based on the specified image

      * @param image Image The original image

      * @return Icon The icon based on the image

      */

      public static ImageIcon getIcon(Image image) {

      if (image == null)

      return null;

      return new ImageIcon(image);

      }

      }

      MainFrame.java

      import java.awt.EventQueue;

      import java.awt.event.ItemEvent;

      import java.awt.event.ItemListener;

      import java.util.Map;

      import java.util.Set;

      import javax.swing.DefaultComboBoxModel;

      import javax.swing.JButton;

      import javax.swing.JComboBox;

      import javax.swing.JFrame;

      import javax.swing.JLabel;

      import javax.swing.JPanel;

      import javax.swing.JTextField;

      import javax.swing.SwingConstants;

      import javax.swing.UIManager;

      import javax.swing.border.TitledBorder;

      public class MainFrame extends JFrame {

      /**

      *

      */

      private static final long serialVersionUID = -4595347311922711984L;

      private JTextField textField_3;

      private JTextField textField_1;

      private JComboBox comboBox_1;

      private JTextField textField;

      private JComboBox cityComboBox;

      private JComboBox comboBox;

      /**

      * Launch the application

      *

      * @param args

      */

      public static void main(String args[]) {

      EventQueue.invokeLater(new Runnable() {

      public void run() {

      try {

      UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");

  • 相关阅读:
    转载ORACLE批量绑定FORALL与BULK COLLECT
    Oracle Locking Survival Guide
    转载:TOAD中查看执行计划
    Oracle 9i/10g编程艺术笔记第七章 并发与多版本
    C#调用Oracle存储过程返回多结果集
    转载oracle 字符集查看与修改
    转载:Oracle的优化器(Optimizer)
    Oracle 随笔
    转载:Oracle中SQL语句执行效率的查找与解决
    当查询和设置需要输入Pn时界面的处理方法
  • 原文地址:https://www.cnblogs.com/-zpy/p/5016273.html
Copyright © 2020-2023  润新知