When I use setFont( ) method to set the string'sfont, the result font is another one.

B

Bruce Sam

This problem happen in a very big java project and the project run in a
multithread environment.It is impossible to list all the code in here
because it is so large.The genernal situation is I have two JavaBean in
a screen which one is typer,another one is list.Each bean use different
font.But I find a very strange phenomenon.the font of the typer bean is
correct sometimes,but sometimes is wrong when I run the project.and I
see the font of typer bean in fact is impacted by list bean.I have
debug the code through many way.You see,in the piece of the java
code,After I setted the font,I printed it,the printed result showed
that the font is I need.But after excuted the drawString(),the display
result is not I need because in fact the font has been changed to an
unexcepted one. Because I don't understanding the mechanism of java
drawing,I can't debug deeply.My question is list below:
1.If I set the font,the drawString method is really draw the string
what I want.
2.What do you think of my problem?

==============a piece of java code==================
private m_font = new Font("bold",Font.BOLD, 18);
....
public void draw(Graphics g)
{
g.setFont(m_font);
g.setColor(m_TextColorNoFocus);
System.out.println(g.getFont());
g.drawString(m_keyboardString,20,21);
}
====================================================
 
V

VK

What kind of chars in your strings? May it contain sometimes chars above
007F (beyond
the low-ASCII set)? Like "British 20 [pound sign]"

Just one of possibilities...
 
V

VK

private m_font = new Font("bold",Font.BOLD, 18);

"bold" is an actual font name?
is it installed properly on the machines of question?
 
B

Bruce Sam

I have tested my java project in four or five PC machine.The problem is
same.So I thinked it is may be another reason that I don't know.
 
B

Bruce Sam

Thanks.I only use alphanumeric.The problem happen in two bean
integrated together.If I only use typer bean,the font display normal.So
I thinked the reason may be another one.But I can't find the answer now
and I am still debuging it.This is a very difficult problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,444
Messages
2,571,709
Members
48,796
Latest member
Greg L.
Top