admin 管理员组文章数量: 1184232
2024年3月6日发(作者:零代码开发app)
}}port ;import t;import edInputStream;import rayOutputStream;import putStream;import ption;import tream;import p;import or;import con;/*** Utility class for managing resources such as colors, fonts, images, etc.** This class may be freely distributed as part of any application or plugin.** Copyright (c) 2003 - 2004, Instantiations, Inc.
All Rights Reserved** @author scheglov_ke*/public class SwingResourceManager {/*** Maps image names to images*/private static HashMap m_ClassImageMap = new HashMap();/*** Returns an image encoded by the specified input stream* @param is InputStream The input stream encoding the image data* @return Image The image encoded by the specified input stream*/private static Image getImage(InputStream is) {
try {ByteArrayOutputStream baos = new ByteArrayOutputStream();byte buf[] = new byte[1024 * 4];while (true) {int n = (buf);if (n == -1)break;(buf, 0, n);}();return aultToolkit().createImage(Array());} catch (Throwable e) {return null;}}/*** Returns an image stored in the file at the specified path relative to the specified class* @param clazz Class The class relative to which to find the image* @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(Class> clazz, String path) {String key = e() + '|' + path;Image image = m_(key);if (image == null) {if ((() > 0) && ((0) == '/')) {String newPath = ing(1, ());image = getImage(new BufferedInputStream(ssLoader().getResourceAsStream(newPath)));} else {image = getImage(ourceAsStream(path));}m_(key, image);}return image;
}/*** 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 + '|' + e() + '|' + path;Image image = m_(key);if (image == null) {try {FileInputStream fis = new FileInputStream(path);image = getImage(fis);m_(key, image);();} 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_().iterator(); t();) {String key = ();if (!With(section + '|'))continue;Image image = m_(key);();();}}/*** 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);}}port ueue;import ent;import stener;import ;import ;import tComboBoxModel;import n;import Box;import ;import ;import ;import ield;import onstants;import ger;import Border;public class MainFrame extends JFrame {/****/private static final long serialVersionUID = -45953473L;
final BackgroundPanel backgroundPanel = new BackgroundPanel();ge(ge(, "/images/"));nds(0, 0, 510, 380);getContentPane().add(backgroundPanel);final JPanel panel = new JPanel();que(false);nds(36, 126, 438, 70);(panel);out(null);der(new TitledBorder(null, "居住地", T_JUSTIFICATION, T_POSITION,null, null));cityComboBox = new JComboBox();nds(245, 25, 124, 27);(cityComboBox);el(new DefaultComboBoxModel(getCity(province)));comboBox = new JComboBox();nds(25, 25, 124, 27);(comboBox);mListener(new ItemListener() {public void itemStateChanged(final ItemEvent e) { // 选项状态更改事件itemChange();}});el(new DefaultComboBoxModel(getProvince())); // 添加省份信息final JLabel label = new JLabel();t("省/直辖市");nds(155, 30, 66, 18);(label);final JLabel label_1 = new JLabel();label_t("市/县");label_nds(375, 30, 37, 18);(label_1);final JLabel label_2 = new JLabel();label_nds(36, 43, 65, 18);
String selectProvince = (String) ectedItem();AllItems(); // 清空市/县列表String[] arrCity = getCity(selectProvince); // 获取市/县el(new DefaultComboBoxModel(arrCity)); // 重新添加市/县列表的值}}效果如图:
版权声明:本文标题:java二级级联_Java实现Map集合二级联动 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/b/1709729519a544538.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论