• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Changing Fonts

 
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic