• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why isn't the label's font changing?

 
Mohammed Azeem
Ranch Hand
Posts: 51
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

Another experiment to see if I've understood anything from my studying.

It's very simple, I've added an AWT component/control (specifically a Choice object to a Frame. It's a pop-up menu by any other name.

Above the pop-up, there's a label. I'm trying to change its font to no success.

* I create Label object called label1: Label label1 = new Label("This is a pop-up")
* I create a Font object called f: Font f = new Font("Times New Roman, Font.BOLD, 18)
* I apply the new font to the label: (in AFrame's constructor) label1,setFont(f)

When displayed the label's font seems to be stuck on Arialor something similar. Changing the point size however does have an effect.


Any help would be greatly appreciated.

Thanks,





 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Works for me. Please refer image below.

On a related note, you should really dump awt and switch to Swing. Also using null layouts and bounds is a big no no. Use a proper layout manager instead
Screenshot from 2015-02-20 11:47:11.png
[Thumbnail for Screenshot from 2015-02-20 11:47:11.png]
 
Paul Clapham
Sheriff
Posts: 21882
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I vaguely recall from over a decade ago that you used to have to mess about with the Java configuration to get fonts to work correctly.

But I never actually wrote an AWT application because it was replaced with Swing in 1998. So I would respectfully suggest that if you are spending time learning AWT, you are wasting that time. The chances of your encountering an AWT application at your future place of work are essentially zero.
 
Mohammed Azeem
Ranch Hand
Posts: 51
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh well, thank you Paul.

At least I know that my thinking was broadly correct.

Yes, I will look into the configurations thing.

Most helpful.

 
Mohammed Azeem
Ranch Hand
Posts: 51
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I really can't wait to move on to Swing or even FX and I would hate others to think I am ignoring their advice.

Slight Asberger's - or bipolar 'light' - Oh God, both ) - call it what you will.

There's a crazy rationale to it all: Swing is derived from AWT and, when I come to it, I might find that Java FX is based on them both so AWT might be a good grounding for the future. I hope I don't turn out like those crazy old anachronisms that can't let go and find myself obsessively trapped in the AWT world.

Enough !

Thank you anyway.

 
Mohammed Azeem
Ranch Hand
Posts: 51
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry forgot to thank Manesh.

Thank you Manesh.
 
Rob Camick
Ranch Hand
Posts: 2699
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's a crazy rationale to it all


Yes, it is crazy and completely unnecessary.

so AWT might be a good grounding for the future.


Not really. Swing does some things differently than AWT and there is no reason to learn how to do things the AWT way. Just go directly to Swing.

Start by learning from the examples in the Swing tutorial.

Yes, I will look into the configurations thing.


That would be a waste of time. Chances are you will never need to know how to do that and I've never needed it in the last two decades. It will not help you with Swing of JavaFX. Spend you time learning something that might actually be useful.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!