Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

StyleConstants  RSS feed

 
Mohamad Obagi
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys

have 3 questions

1- How to make styleconstants set font as plain
2- how to make Styleconstants set font as bold AND italic
3- how to give SimpleAttributeSet a default style;

regards,
 
Rob Spoor
Sheriff
Posts: 20904
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mohamad Obagi:
1- How to make styleconstants set font as plain

StyleConstants.setBold(attributeSet, false);
StyleConstants.setItalic(attributeSet, false);
StyleConstants.setStrikeThrough(attributeSet, false);
StyleConstants.setUnderline(attributeSet, false);

That should do it. Plain basically means all the others turned off.

2- how to make Styleconstants set font as bold AND italic

See my above answer. With StyleConstants you don't remove all other attributes when you set a new one - you add it to the existing. Only the attribute you are setting will be overwritten.

3- how to give SimpleAttributeSet a default style;

What do you mean with default style? If you mean a certain set set of style attributes, you could create a utility method:

Then call that method each time you have created an attribute set.
 
Mohamad Obagi
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh thanks a lot was doing it this way but wasn't working don't know why.. it worked now


ill just create another style and use it as default

thanks again
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!