0

I have a JTextPane and when a user clicks a button, I want certain portions of the text to "hide"

StyleConstants.setFontSize(style,0);
StyleConstants.setForeground(style,textPane.getBackground());

accomplished this perfectly, however it is also raising the following error:

Java[20425] : CGAffineTransformInvert: singular matrix.

Is there a way to accomplish what I'm doing (set font size to 0) without getting this error?

Thanks!

mKorbel
  • 109,525
  • 20
  • 134
  • 319
Simon Rubin
  • 198
  • 11
  • Why can't you update the text in `JTextPane` after removing certain portions of the text. – Braj Jun 03 '14 at 16:33
  • The TextPane logs different types of messages (order matters). The user has a set of JRadioButtons associated with separate message types. They can choose which messages they want displayed in the textPane. I thought an easy way to do this was to have a style associated with each message. When the user deselects a button, all text of that message type "disappears" (0 font size), if the user later selects that button I'd want the text to be visible again – Simon Rubin Jun 03 '14 at 16:39
  • use highlighter and set the same background color and selection color that looks like hiding the text. Read [JTextPane highlight text](http://stackoverflow.com/questions/5674128/jtextpane-highlight-text) but not a good idea. – Braj Jun 03 '14 at 16:40

1 Answers1

1

The TextPane logs different types of messages (order matters).

I'm guessing that each message appears on a separate line?

If so, then maybe you can use a JTable to display each message in a separate row. You could add a second column to the TableModel to contain the message type.

Then you can use the JTable built in filtering support to control which messages are displayed based on which radio buttons are selected.

Check out the RowFilter class. It supports "and" or "or" filters which you can use to control which messages to display.

camickr
  • 321,443
  • 19
  • 166
  • 288