B
Barkster
I'm trying to set the alignment when inserting an icon into a
jtextpane to center when I insert but I'm a little confused on how to
do it? I'm trying to do it this way but of course it doesn't work?
MutableAttributeSet attr = new
SimpleAttributeSet();
doc.setText("");
StyleConstants.setAlignment(attr,
StyleConstants.ALIGN_CENTER);
StyleConstants.setIcon(attr, ImgThumbnail);
//try to insert image
try {
(this.doc.getDocument()).insertString(
doc.getCaretPosition(),
" ", attr);
new StyledEditorKit.AlignmentAction("",
StyleConstants.ALIGN_CENTER);
} catch (Exception ex) {
JOptionPane.showMessageDialog(this,
ex,
"",
JOptionPane.ERROR_MESSAGE);
}
jtextpane to center when I insert but I'm a little confused on how to
do it? I'm trying to do it this way but of course it doesn't work?
MutableAttributeSet attr = new
SimpleAttributeSet();
doc.setText("");
StyleConstants.setAlignment(attr,
StyleConstants.ALIGN_CENTER);
StyleConstants.setIcon(attr, ImgThumbnail);
//try to insert image
try {
(this.doc.getDocument()).insertString(
doc.getCaretPosition(),
" ", attr);
new StyledEditorKit.AlignmentAction("",
StyleConstants.ALIGN_CENTER);
} catch (Exception ex) {
JOptionPane.showMessageDialog(this,
ex,
"",
JOptionPane.ERROR_MESSAGE);
}