Results 1 to 2 of 2
- 12-03-2009, 04:34 AM #1
Member
- Join Date
- Dec 2009
- Posts
- 2
- Rep Power
- 0
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:
textfield.setFont(font1);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:textfield.setHorizontalTextPostion.CENTER textfield.setVerticalTextPostion.CENTER
-
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
-
change text size in all GUI components
By itaipee in forum AWT / SwingReplies: 2Last Post: 08-07-2009, 04:59 AM -
How to change font/ font color etc in a graphic object using JCombobox?
By JavaInLove in forum AWT / SwingReplies: 5Last Post: 04-25-2009, 08:00 PM -
what is that method to change the size of a font in an applet?
By javanoobita in forum New To JavaReplies: 4Last Post: 02-22-2009, 06:31 AM -
How to use TextAttribute class to change color and font of a text
By Java Tip in forum java.awtReplies: 0Last Post: 06-25-2008, 10:33 AM -
how to set font size for a xml value
By bala_kj in forum Advanced JavaReplies: 3Last Post: 04-01-2008, 11:00 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks