I am facing a problem in JTextPane. Actually we are creating a editor like application in Java Swing. In JtextPane we type the matter and set some metter as heading1, heading2 so on as user required and some matter as simple story. My problem is that how can we seperate or find which text is heading and which is normal text. Please help me.


If you want to be able to programmatically find the heading, you first have to define what separates the heading from the other text. It is all just text in a JTextPane, right?

actually we have a form on which we have placed a JTextpane. There is also a toolbar which have a combobox which defines the styles for heading and normal text like 16bold, 18bold etc. If the user does not select any style the matter will be simple story. If the user select some matter and apply a style sheet like 16Bold the selectable matter will be converted to the heading. My problem starts from here. The Heading area should be seperated from the normal text area. it will be like the textbox is devided into two parts. the first one holds the heading and the other one holds the normal matter. How can we do it?