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);
}
====================================================
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);
}
====================================================