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.

Results 1 to 3 of 3

Thread: About Title border in jscrollpane

  1. #1
    Member
    Join Date
    Aug 2009
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question About Title border in jscrollpane

    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.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,297
    Thanks
    180
    Thanked 824 Times in 767 Posts
    Blog Entries
    5

    Default Re: About Title border in jscrollpane

    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);

  3. #3
    Member
    Join Date
    Aug 2009
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Re: About Title border in jscrollpane

    Thanks for your reply copeg.Any other possible way?Which borders allow two different size of text in the same title?

Similar Threads

  1. JFrame, frame's title doesnt appear.
    By chronoz13 in forum AWT / Java Swing
    Replies: 1
    Last Post: November 26th, 2009, 02:38 PM
  2. Data is getting corrupt in Jscrollpane
    By ruchika in forum AWT / Java Swing
    Replies: 0
    Last Post: September 1st, 2009, 10:41 AM
  3. Replies: 1
    Last Post: May 21st, 2009, 03:41 AM