Results 1 to 5 of 5

Thread: String Bold

  1. #1
    Xystus777 is offline Member
    Join Date
    Jan 2009
    Posts
    22
    Rep Power
    0

    Default String Bold

    Is there a way to make my string bold?

    I have a string:

    Java Code:
    String nameTitle = "Name: ";
    Now how can I make that bold?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Strings are just that, strings. They don't have bold, font, or any other "properties". Now if you want to make a JLabel Bold, then that's different -- change the label's Font.

  3. #3
    Xystus777 is offline Member
    Join Date
    Jan 2009
    Posts
    22
    Rep Power
    0

    Default

    that's what i meant, thanks

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    You will find much help in the Java API and the Sun Swing Tutorials.

    I recommend that you look at the JLabel API and the setFont(...) method. Then have a look at the Font API where you will see how to set the Font to bold. Then come on back if you still don't understand something there.

    edit: If you aren't going to be setting anything more than the bold attribute, then have a look at deriveFont:

    Java Code:
    myLabel.setFont(myLabel.getFont().deriveFont(Font.BOLD));
    Last edited by Fubarable; 01-20-2009 at 08:01 AM.

  5. #5
    Xystus777 is offline Member
    Join Date
    Jan 2009
    Posts
    22
    Rep Power
    0

Similar Threads

  1. Bold Italic function in Swing
    By Java.child in forum AWT / Swing
    Replies: 2
    Last Post: 02-19-2009, 04:08 PM
  2. Replies: 5
    Last Post: 01-11-2009, 11:12 AM
  3. Returning a string (Partly Bold)
    By TampaTechGuy in forum New To Java
    Replies: 3
    Last Post: 02-03-2008, 10:54 AM
  4. Replies: 0
    Last Post: 11-20-2007, 05:59 PM
  5. Replies: 1
    Last Post: 08-03-2007, 11:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •