This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes A conundrum with seting Graphics font size Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "A conundrum with seting Graphics font size" Watch "A conundrum with seting Graphics font size" New topic
Author

A conundrum with seting Graphics font size

Alejandro Barrero
Ranch Hand

Joined: Aug 01, 2005
Posts: 309
Setting the font size is not working. This is the code:

However, in the same application the following works:

I have tried variations, Graphics2D, whatever. I don't know what I am doing wrong.


Your help will be greatly appreciated,
Alejandro Barrero
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2152
    
    7
Post your SSCCE demonstrating the problem.
Alejandro Barrero
Ranch Hand

Joined: Aug 01, 2005
Posts: 309
Rob:

These are my three classes:


Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2152
    
    7
That is NOT a SSCCE. Your question is about font size. You need to create a simple program that does some simple custom painting on a panel. It will probably be about 20-30 lines of code. Once you get that simple program working you can compare that code with your real program to see what the difference is. Once you know what the difference is you should be able to solve your problem.
Alejandro Barrero
Ranch Hand

Joined: Aug 01, 2005
Posts: 309
Thank you for your patience Rob. I created a simple JPanel:

I put the panel in a form and it works fine. I am not claiming that the method dawString of Graphics doesn't work. My problem is that in the classes that I presented earlier it doesn't behave as expected and I don't know what I am doing wrong.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2152
    
    7
So then you start modifying the simple example so that it looks more like your real program. Then when it stops working you have isolated the problem. Then maybe we can help you.
Alejandro Barrero
Ranch Hand

Joined: Aug 01, 2005
Posts: 309
Thank you Rob for your good advise. I removed code from my original classes and copied the code from the new class and now everything works. No w the problem is that I am not getting key pressed events in my new class, but it is so simple that I will post a new question with it.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: A conundrum with seting Graphics font size
 
Similar Threads
Mouse and Key Listeners don't work on JPanel
GlassPane displays flickering
Drawing on a JPanel fails
Problem with ImageIO.write
JPanel paint component called many times