Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retaining Superscript and Subscript fronts in Vector

 
Con Karega
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on a project in which I am required to store the text written in a JTextPane to an XML File. During this I take the data one by one and add the various entries in the TextPane
to a vector and then finally put the content of vector in the XML File.
The Problem that I am facing is that when the user enters a superscript or a subscript in the TextPane the vector takes it as a normal text so that when I try and print the contents
of vector I see normal text and not Superscript and subscript.
Can someone help me in solving this problem where I should be able to take the text in the way it is entered all the way to the XMl File via the Vector.
We are allowing the addition of SuperScript or subscript through the following code:
//I GET THIS FROM A FORUM AND IT WORKS FINE.
Font f = new Font("Arial",Font.PLAIN,15);
MutableAttributeSet mas = new SimpleAttributeSet();
StyleConstants.setFontFamily(mas,f.getFamily());
StyleConstants.setFontSize(mas,f.getSize());
StyleConstants.setSuperscript(mas,false);
StyleConstants.setSubscript(mas,true);
presentTextPane.setCharacterAttributes(mas,false);

Thanks,
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic