Results 1 to 2 of 2
  1. #1
    stayfierce is offline Member
    Join Date
    Dec 2009
    Rep Power

    Default Change the Font Size and Text Position

    I am trying to change the font size of a text field. I would like the font that is typed in the text field to be bigger and bolded.

    I have tried this, but it does does not work:

    Java Code:
    Font font1 = new Font("SansSerif", Font.BOLD, 20);
    JTextField textfield = new JTextField ();

    Also, I want the texted to be centered in the textfield. I have used this:

    Java Code:

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power


    Just creating a font does nothing. You have to set the JTextField's font via setFont. Note that this will only work on the textfield that is specifically set this way. If you want to change ALL textfields, you'll need to look into look and feel.

Similar Threads

  1. change text size in all GUI components
    By itaipee in forum AWT / Swing
    Replies: 2
    Last Post: 08-07-2009, 04:59 AM
  2. Replies: 5
    Last Post: 04-25-2009, 08:00 PM
  3. Replies: 4
    Last Post: 02-22-2009, 06:31 AM
  4. Replies: 0
    Last Post: 06-25-2008, 10:33 AM
  5. how to set font size for a xml value
    By bala_kj in forum Advanced Java
    Replies: 3
    Last Post: 04-01-2008, 11:00 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