public void setBulletType(int type) {

		Element[] elem = getSelectedParagraphs();
		if (elem == null)
			return;

		float currentIndent = 0.0f;
		AttributeSet as = null;
		StyledDocument doc = getStyledDocument();
		Element head = null;
		Icon icon = null;
		for (Element e : elem) {

			as = e.getAttributes();
			currentIndent = StyleConstants.getLeftIndent(as);
			head = doc.getCharacterElement(e.getStartOffset());
			icon = StyleConstants.getIcon(head.getAttributes());

			if (!(icon instanceof BulletIcon)) { // this includes null
				Icon bi = BulletIcon.get(type);
				if (bi != null) {
					SimpleAttributeSet sas = new SimpleAttributeSet(as);
					StyleConstants.setLeftIndent(sas, currentIndent + INDENT_STEP);
					doc.setParagraphAttributes(e.getStartOffset(), e.getEndOffset() - e.getStartOffset(), sas, false);
					as = new SimpleAttributeSet();
					StyleConstants.setIcon((MutableAttributeSet) as, bi);
					try {
						doc.insertString(e.getStartOffset(), "  ", null);
						doc.insertString(e.getStartOffset(), " ", as);
					} catch (BadLocationException ble) {
						ble.printStackTrace();
					}
				}
			} else {
				Icon bi = BulletIcon.get(type);
				if (bi == null) {
					SimpleAttributeSet sas = new SimpleAttributeSet(as);
					StyleConstants.setLeftIndent(sas, currentIndent - INDENT_STEP > 0 ? currentIndent - INDENT_STEP : 0);
					doc.setParagraphAttributes(e.getStartOffset(), e.getEndOffset() - e.getStartOffset(), sas, false);
					try {
						doc.remove(e.getStartOffset(), 3);
					} catch (BadLocationException ble) {
						ble.printStackTrace();
					}
				} else {
					as = new SimpleAttributeSet();
					StyleConstants.setIcon((MutableAttributeSet) as, bi);
					try {
						doc.remove(e.getStartOffset(), 1);
						doc.insertString(e.getStartOffset(), " ", as);
					} catch (BadLocationException ble) {
						ble.printStackTrace();
					}
				}
			}

		}

	}