Results 1 to 2 of 2
- 12-03-2009, 04:34 AM #1Member
- Join Date
- Dec 2009
- Rep Power
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:
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:
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.
- By itaipee in forum AWT / SwingReplies: 2Last Post: 08-07-2009, 04:59 AM
- By JavaInLove in forum AWT / SwingReplies: 5Last Post: 04-25-2009, 08:00 PM
- By javanoobita in forum New To JavaReplies: 4Last Post: 02-22-2009, 06:31 AM
- By Java Tip in forum java.awtReplies: 0Last Post: 06-25-2008, 10:33 AM
- By bala_kj in forum Advanced JavaReplies: 3Last Post: 04-01-2008, 11:00 AM