public void insertIcon() {
		JFileChooser chooser = new JFileChooser();
		FileNameExtensionFilter filter = new FileNameExtensionFilter(
				"jpg & gif图像文件", "jpg", "JPG", "JPEG", "GIF", "gif");// 设置可选文件后缀名
		chooser.setAcceptAllFileFilterUsed(false);// 取消所有文件选项
		chooser.setFileFilter(filter);
		// final JLabel label=new JLabel();
		final PaintPanel panel = new PaintPanel();
		panel.setBorder(new BevelBorder(BevelBorder.LOWERED, null, null, null,
				null));
		panel.setPreferredSize(new Dimension(300, 300));
		chooser.setAccessory(panel);
		chooser.addPropertyChangeListener(new PropertyChangeListener() {
			public void propertyChange(PropertyChangeEvent e) {
				if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY == e
						.getPropertyName()) {
					File picfile = (File) e.getNewValue();
					if (picfile != null && picfile.isFile()) {

						// String imagePath = picfile.getPath();
						// panel.setImgPath(imagePath);
						Image image;
						try {
							image = Toolkit.getDefaultToolkit().getImage(
									picfile.toURI().toURL());
							panel.setImage(image);
							panel.repaint();
						} catch (MalformedURLException e1) {
							// TODO Auto-generated catch block
							e1.printStackTrace();
						}

					}
				}
			}
		});
		if (chooser.showOpenDialog(frame) == 0) {
			File file = chooser.getSelectedFile();
			if (file.exists()) {

				ImageIcon icon = new ImageIcon(file.getPath());
				textPane.insertIcon(icon);
			}
		}

	}