• Post Reply Bookmark Topic Watch Topic
  • New Topic

Changing Fonts  RSS feed

 
Davy Kelly
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey everyone,

I have been at the API for most of the day as I am trying to make a small program.

I cannot for the life of me understand how to change the font of something.

I have a JTextField and the String I want to show in this field I want to be bold.

How do I do this?

davy
 
Garrett Rowe
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you can use a JLabel instead of a JTextField its easy since JLabels accept html markups.


[ February 23, 2007: Message edited by: Garrett Rowe ]
 
Davy Kelly
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,

But I will need to be able to just pick a string, not give it a specific string, cause the JTextField or JLabel will change dynamically.

I will be asking more questions later about this program, more just to get ideas mainly on the best way to implement it...

but the label or text field will be a date that will look like this:
Friday 23 February 2007
that will change dynamically the current date and from a date picker.

so I think your idea might not work.

I tried to follow the API, but I got lost and nothing was working.

davy

EDIT: Sorry I made a unique String that had the HTML and the variable that will change, this worked. Thanks
[ February 23, 2007: Message edited by: Davy Kelly ]
 
Paul Clapham
Sheriff
Posts: 22375
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Set the font of the JTextField to the bold version of its current font:
 
Davy Kelly
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey everyone, now that I have got that set, I was also wanting to center it, as when I press my button the label moves to the right only once, I send a date to a text area below the label.

I centred it ok, but still when I press the button to send a date to the text area below the label, the label moves only once to the right, no matter how many times I send a date to the text area

ik
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!