Hi all,
Is it possible to insert two different styles of text(example: bold and plain)in a title border?Please do me the favor.Thanks in advance.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Hi all,
Is it possible to insert two different styles of text(example: bold and plain)in a title border?Please do me the favor.Thanks in advance.
I don't think its trivial. Lots of swing components allow html to do simple font changes but TitledBorder does not. A workaround is a) google "TitledBorder source code" to retrieve its source code b) modify the paintBorder function in a way that draws each string accordingly using the appropriate font c) incorporate this new object into your project (I'd recommend calling it something else so there isn't conflict with the swing package TitledBorder). Here is an example of what should be done in the paintBorder function to draw "HERE Bold" as the border. If can be modified appropriately for your text
g.drawString("HERE ", textLoc.x, textLoc.y); g.setFont( font.deriveFont(Font.BOLD ) ); g.drawString("Bold", textLoc.x + fm.stringWidth("HERE "), textLoc.y);
Thanks for your reply copeg.Any other possible way?Which borders allow two different size of text in the same title?