Java 2D and Text Rendering Problems.
Hi,
My first post of many.
I have a little problem let me tell you:
Setting the scene.
I have has this problem occurring with an application that I am developing. It appears to occur on some machines more than others and seems independent of processor speeds, memory e.t.c.
What I have is a JPanel (workspace panel), within this is contained other JPanels (component panels).
These component panels contain various symbols and text drawn via JavaGraphics2D.
The component tiles are all of equal size and arranged in a gird like formation with the gridbag layout. All component panels and the workspace panel have double buffering turned on.
These tiles can then build up an image i.e. a flow chart. Each tile contains a mouse listener so that its is highlighted when the mouse is over the component and de-highlighted when it is removed.
However, occasionally the program tends to crash. Sometimes this happens when a another component such as a JDialog obscures part of the workspace panel. However less frequently it can happen when the graphics of the workspace panel are updating. For example during highlighting or adding component panels.
The crash comes in a variety of forms but seems to relate to the Text rendering of Java2D. It causes the program to freeze. This problem never occurred before I migrated to Java2D from the standard Java Graphics package. The three most recent variants of the exception stack dumps are shown below.
Exception Stack Dumps:
ONE:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at sun.java2d.loops.DrawGlyphList.DrawGlyphList(Native Method)
at sun.java2d.pipe.SolidTextRenderer.drawGlyphList(SolidTextRenderer.java:36)
at sun.java2d.pipe.GlyphListPipe.drawString(GlyphListPipe.java:53)
at sun.java2d.SunGraphics2D.drawString(SunGraphics2D.java:2642)
at GPTool.IfGraphic.paint(IfGraphic.java:223)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4963)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4916)
at javax.swing.JComponent._paintImmediately(JComponent.java:4859)
at javax.swing.JComponent.paintImmediately(JComponent.java:4666)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:451)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:114)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:158)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
TWO
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at sun.font.FileFont.getGlyphImage(Native Method)
at sun.font.FileFontStrike.getSlot0GlyphImagePtrs(FileFontStrike.java:388)
at sun.font.CompositeStrike.getGlyphImagePtrs(CompositeStrike.java:97)
at sun.font.GlyphList.mapChars(GlyphList.java:211)
at sun.font.GlyphList.setFromString(GlyphList.java:186)
at sun.java2d.pipe.GlyphListPipe.drawString(GlyphListPipe.java:52)
at sun.java2d.SunGraphics2D.drawString(SunGraphics2D.java:2642)
at GPTool.AssignGraphic.paint(AssignGraphic.java:93)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JViewport.paint(JViewport.java:728)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4963)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4916)
at javax.swing.JComponent._paintImmediately(JComponent.java:4859)
at javax.swing.JComponent.paintImmediately(JComponent.java:4666)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:451)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:114)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:158)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
THREE
java.lang.NullPointerException
at sun.java2d.loops.DrawGlyphList.DrawGlyphList(Native Method)
at sun.java2d.pipe.SolidTextRenderer.drawGlyphList(SolidTextRenderer.java:36)
at sun.java2d.pipe.GlyphListPipe.drawString(GlyphListPipe.java:53)
at sun.java2d.SunGraphics2D.drawString(SunGraphics2D.java:2642)
at GPTool.PrintGraphic.paint(PrintGraphic.java:96)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JViewport.paint(JViewport.java:728)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4963)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4916)
at javax.swing.JComponent._paintImmediately(JComponent.java:4859)
at javax.swing.JComponent.paintImmediately(JComponent.java:4666)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:451)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:114)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:158)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Exception in thread "AWT-EventQueue-0" java.lang.InternalError: Win32OSSD_Lock cannot nest locks
at sun.java2d.loops.Blit.Blit(Native Method)
at sun.java2d.pipe.AlphaPaintPipe.renderPathTile(AlphaPaintPipe.java:138)
at sun.java2d.pipe.SpanShapeRenderer$Composite.renderBox(SpanShapeRenderer.java:42)
at sun.java2d.pipe.SpanShapeRenderer.spanClipLoop(SpanShapeRenderer.java:232)
at sun.java2d.pipe.SpanShapeRenderer.renderSpans(SpanShapeRenderer.java:215)
at sun.java2d.pipe.SpanShapeRenderer.renderPath(SpanShapeRenderer.java:192)
at sun.java2d.pipe.SpanShapeRenderer.fill(SpanShapeRenderer.java:125)
at sun.java2d.pipe.ValidatePipe.fill(ValidatePipe.java:142)
at sun.java2d.SunGraphics2D.fill(SunGraphics2D.java:2258)
at GPTool.TerminatorGraphic.paint(TerminatorGraphic.java:57)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JViewport.paint(JViewport.java:728)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4963)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4916)
at javax.swing.JComponent._paintImmediately(JComponent.java:4859)
at javax.swing.JComponent.paintImmediately(JComponent.java:4666)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:451)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:114)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:158)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
I have taken many a look on the forums around the internet but never found one the specifically answers this problem?Please help
Thanks in advance....
Andrew.
Message was edited by:
Scottie_UK
Message was edited by:
Scottie_UK
First off, there are so many lines in that stack trace that its meaningless...
If you simply read the errors then you'll know what to do to fix it... for example:
1) Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException... Well, do you have a null sending prevention if statement? There you go... Maybe you're sending some String or other value that is set to null, try putting a
if ( value != null )
{
DealWithValue( value );
}
I wanna know how that works out.
Yes, but the problem is not occouring within my code.I dont know what the null variable / object is or why it is happening thats my point of posting.I am wondering if anyone else can shed some light on the situation, having experienced somthing similar.
What version of jdk are you using?It seems you are directly calling sun.* classes and this is generally bad idea. Why not call java.awt.Graphics.drawString()?
> Yes, but the problem is not occouring within my
> code.
You say that, but are you certain? The stack trace contains this line:
"at GPTool.IfGraphic.paint(IfGraphic.java:223)"
This is not a JDK class. If you aren't using any 3rd party libraries, then this must be your class. Similar classes appear in the other two stack traces as well.
>
> I dont know what the null variable / object is or why
> it is happening thats my point of posting.
>
Post the code from the paint() method of the 'IfGraphic' class. And also point out which line in that class is line 223.
Here is the class that displays the IfGraphic
[IFGraphic Class
public class IfGraphic extends Graphic
{
private String cond;
private String condText;
private Color t;
private int tSize;
private Color f;
private int fSize;
private boolean rightArrow;
private boolean leftArrow;
public boolean leftSide;
private boolean hasElse;
//constructor
public IfGraphic(int viewSize, int draw, String conditions, boolean inHasElse)
{
try
{
cond = conditions;
hasElse = inHasElse;
jbInit(viewSize,draw,conditions);
}
catch(Exception e)
{
e.printStackTrace();
}
}
//Initialisation
private void jbInit(int viewSize, int draw, String conditions) throws Exception
{
t = Color.red;
f = Color.red;
tSize = 0;
fSize = 0;
leftArrow = false;
rightArrow = false;
drawOrder=draw;
percentage =viewSize;
size = (new Dimension (viewSize,viewSize));
this.setSize(size);
this.setVisible(true);
cond = getConditions();
if (cond.length() < 10)
condText = cond;
else
condText=cond.substring(0,10) +"...";
}//=========================================================================
//============================================================================
//Method: getConditionsReturns: String
//Gets the conditions (arguments) as a string
//============================================================================
public String getConditions()
{
return cond;
}
//============================================================================
//Method: setConditionsParams: String
//Sets the conditions (arguments) as a string
//============================================================================
public void setCondtions(String conditions)
{
cond = conditions;
}
//============================================================================
//Method: flowHighlightingparams: boolean
//Turns clickColor on
//============================================================================
public void flowHiglighting(boolean b, boolean selTrue)
{
mouseOverThis = b;
colorChange();
//if tIs True then highlight T
if (selTrue == false)
{
t = Color.yellow;
f = Color.red;
tSize = 10;
fSize = 0;
rightArrow = true;
leftArrow = false;
}else//highlight the F
{
f = Color.yellow;
t = Color.red;
tSize = 0;
fSize = 10;
leftArrow = true;
rightArrow = false;
}
this.repaint();
}//===========================================================================
//============================================================================
//Method: getArrowState()Returns: int
//Returns true if the left side of the if is selected and false if the right
//side is selected
//============================================================================
public boolean getArrowState()
{
boolean retBool = false;
if (leftArrow == true & rightArrow ==false)
retBool = true;
else if (leftArrow == false & rightArrow == true)
retBool = false;
else if (leftArrow == rightArrow)
retBool = false;
return retBool;
}
//============================================================================
//============================================================================
//Method: click()params: boolean
//Turns clickColor on
//============================================================================
public void click(boolean b)
{
clickThis = b;
colorChange();
}//===========================================================================
//============================================================================
//Method: colorChange()
//Changes the color based on the color states
//============================================================================
public void colorChange()
{
if (animThis == true)
{
this.setBackground(animColor);
}else if (clickThis == true)
{
this.setBackground(clickColor);
}else if (mouseOverThis == true)
{
this.setBackground(mouseOverColor);
}else
{
t = Color.red;
f = Color.red;
rightArrow = false;
leftArrow = false;
tSize = 0;
fSize = 0;
this.setBackground(null);
}//end if
this.repaint();
}//===========================================================================
//============================================================================
//Method: paint
//Performs the actual draw of the component
//============================================================================
public void paint (Graphics G )
{
//diamond points
int xValues[]={s(50),s(99),s(50),s(1)};
int yValues[]={s(33),s(63),s(92),s(63)};
super.paint (G);
Graphics2D g2d = (Graphics2D)G;
g2d.setColor(Color.black);
g2d.setStroke(new BasicStroke(s(6)));
g2d.draw(new Line2D.Double(s(50), s(0), s(50),s(63)));
g2d.draw(new Line2D.Double(s(0), s(63), s(100),s(63)));
g2d.setStroke(new BasicStroke(s(1)));
//The fill of the component
GradientPaint gradient = new GradientPaint (s(53), s(50), new Color(250,150,250), s(50), s(90), Color.white); // true means to repeat pattern
g2d.setPaint( gradient);
//the outline of the component
g2d.fillPolygon(xValues,yValues,4);
g2d.setColor(Color.black);
g2d.drawPolygon(xValues,yValues,4);
g2d.setColor(Color.BLACK);
g2d.setStroke(new BasicStroke(s(5)));
if (rightArrow == true)
{
g2d.drawLine(s(50),s(33),s(99),s(63));
g2d.drawLine (s(99), s(63),s(50),s(92));
}
else if (leftArrow == true)
{
g2d.drawLine (s(50), s(92),s(1),s(63));
g2d.drawLine(s(1),s(63),s(50),s(33));
}
//The text of the component
g2d.setColor(Color.black);
G.setFont(new Font("SansSerif", Font.BOLD, s(12)));
//if the if has an else show this in its name
if (hasElse == false)
G.drawString("IF" ,s(48),s(49));
else
G.drawString("IF_E" ,s(40),s(49));
g2d.setColor(Color.blue);
g2d.drawString(condText ,s(20),s(67));
G.setFont(new Font("SansSerif", Font.BOLD, s(14+fSize)));
g2d.setColor(f);
G.drawString("F",s((fSize/2)),s(59));
G.setFont(new Font("SansSerif", Font.BOLD, s(14+tSize)));
g2d.setColor(t);
G.drawString("T",s(92-(tSize/2)),s(59));
//g2d.create();
}//===========================================================================
}//=============================================================================
[Graphic
IfGraphic inherits from this class.
public class Graphic extends JPanel
{
protected Dimension size = new Dimension();
protected int percentage;
protected int drawOrder;
//The colours
protected Color clickColor;
protected Color mouseOverColor;
protected Color animColor;
//The color states
boolean clickThis;
boolean mouseOverThis;
boolean animThis;
//the general font used for the components
protected Font gFont;
//============================================================================
//No argument constructor
//============================================================================
public Graphic()
{
this.setDoubleBuffered(true);
this.setBackground(null);
//The color defaults
clickColor = new Color (220,220,220);
mouseOverColor = new Color (160,160,160);
animColor = new Color(255,255,255);
//the default color states
clickThis = false;
mouseOverThis = false;
animThis = false;
}//===========================================================================
//============================================================================
//Constructor with arguments
//============================================================================
public Graphic(int viewSize, int draw)
{
try
{
drawOrder = draw;
this.setDoubleBuffered(true);
this.setBackground(null);
//the color defaults
clickColor = new Color (220,220,220);
mouseOverColor = new Color (160,160,160);
animColor = new Color(255,255,255);
//the default color states
clickThis = false;
mouseOverThis = false;
animThis = false;
}
catch(Exception e)
{
e.printStackTrace();
}
}//===========================================================================
//============================================================================
//Method: colorChange()
//Changes the color based on the color states
//============================================================================
public void colorChange()
{
if (animThis == true)
{
this.setBackground(animColor);
}else if (clickThis == true)
{
this.setBackground(clickColor);
}else if (mouseOverThis == true)
{
this.setBackground(mouseOverColor);
}else
{
this.setBackground(null);
}//end if
this.repaint();
}//===========================================================================
//============================================================================
//Method: click()params: boolean
//Turns clickColor on
//============================================================================
public void click(boolean b)
{
clickThis = b;
colorChange();
}//===========================================================================
//============================================================================
//Method: mouseOver()params: boolean
//Turns clickColor on
//============================================================================
public void mouseOver(boolean b)
{
mouseOverThis = b;
colorChange();
}//===========================================================================
//============================================================================
//Method: click()params: boolean
//Turns clickColor on
//============================================================================
public void anim(boolean b)
{
animThis = b;
colorChange();
}//===========================================================================
//============================================================================
//Method: getClickColor()Returns: Color
//Returns mouseClick color of the component
//============================================================================
public Color getClickColor()
{
return clickColor;
}//===========================================================================
//============================================================================
//Method: getAnimColor()Returns: Color
//Returns animation color of the component
//============================================================================
public Color getAnimColor()
{
return animColor;
}//===========================================================================
//============================================================================
//Method: getMouseOverColor()Returns: color
//Returns mouseOver color of the component
//============================================================================
public Color getMouseOverColor()
{
return mouseOverColor;
}//===========================================================================
//============================================================================
//Method: setClickColor()Params: Color
//Sets mouseOver color of the component
//============================================================================
public void setCLickColor(Color c)
{
clickColor = c;
}//===========================================================================
//============================================================================
//Method: seAnimrColor()Params: Color
//Sets mouseOver color of the component
//============================================================================
public void setAnimColor(Color c)
{
animColor = c;
}//===========================================================================
//============================================================================
//Method: setMouseOverColor()Params: Color
//Sets mouseOver color of the component
//============================================================================
public void setMouseOverColor(Color c)
{
mouseOverColor = c;
}//===========================================================================
//============================================================================
//Method: getDrawOrder Returns: Int
//Gets the Draw Order for this component
//============================================================================
public int getDrawOrder()
{
return drawOrder;
}//end getDrawOrder===========================================================
//============================================================================
//Method: setDrawOrder Params: Int
//Sets the Draw Order for this component
//============================================================================
public void setDrawOrder (int d)
{
drawOrder = d;
}//end setDrawOrder
//============================================================================
//============================================================================
//Method: setDimensionsParams: Dimension
//set dimensions for this component
//============================================================================
public void setDimension (Dimension d)
{
size = d;
}//===========================================================================
//============================================================================
//Method: sParams: int
//scales int to percentage
//============================================================================
public int s (int n)
{
float x=n;
if (x !=0)
n=(int)((x/100)*percentage);
return n;
}//===========================================================================
}//END OF CLASS=================================================================
Thanks
Andrew.
Message was edited by:
scottie_uk
Message was edited by:
scottie_uk
Message was edited by:
scottie_uk
Message was edited by:
scottie_uk
Message was edited by:
scottie_uk
A quick perusal of your code........
g2d.drawString(condText ,s(20),s(67));
If 'condText' is 'null', a NullPointerException wil be thrown.
So, under what circumstances can condText be 'null'?
Well, in your
jbInit()
method, you have this:
this.setVisible(true);
cond = getConditions();
if (cond.length() < 10)
condText = cond;
When setVisible()is called, the 'condText' variable still has its default value of 'null'.
The call to setVisible() may result in painting code being called, depending on whether the item being made visible has a parent container that is visible. Since the painting code runs in a different thread, you now have a race condition. If 'cond' is not 'null' and the three lines after the call to setVisible() are executed before the painting code is reached, no NPE will be thrown. If however, the painting code wins the race, you'll get the exception.
There may be other circumstances where 'condText' is null, but I cannot determine that from just the code posted.
Jim S.
Ok thanks for your reply:
However, that did not fix the problem. I have just received the same problem from a simpler class:
To invoke these classes I am iterating through an arraylist of objects and calling the relevant Graphic class (If or Terminator e.t.c) based on the paramiters comming from the objects extracted from this list.
It works 90% of the time. The problems are very random and do not happen with the same grapgic object each time. Although the TerminatorGraphic (Shown below) tends to be the most common class to fail.
The NPE tends to reference this line of code:
G.drawString("Terminate" ,s(22),s(78));
with which I see nothing wrong.
The problem began to appear when I swiched from Java Graphics to Java Graphics 2D. Before then it never gave me any problems.
If it helps I am using Oracle-JDeveloper 10G with its Oracle JDK.
package GPTool;
import java.awt.geom.Line2D;
import java.awt.geom.RoundRectangle2D;
import javax.swing.*; import java.awt.*; import java.awt.event.*;
import java.awt.Dimension;
import java.awt.Color;
public class TerminatorGraphic extends Graphic
{
//Constructor=================================================================
public TerminatorGraphic(int viewSize, int draw)
{
try
{
jbInit(viewSize, draw);
}
catch(Exception e)
{
e.printStackTrace();
}
}//===========================================================================
//Initialisation==============================================================
private void jbInit(int viewSize, int draw) throws Exception
{
drawOrder=draw;
percentage =viewSize;
size = (new Dimension (viewSize,viewSize));
this.setPreferredSize(size);
this.setSize(size);
}//=========================================================================
//============================================================================
//Method: paint
//Performs the actual drawing of the component
//============================================================================
public void paint (Graphics G )
{
super.paint (G);
Graphics2D g2d = (Graphics2D)G;
gFont = new Font("SansSerif", Font.BOLD, s(12));//set up the default font
//the thick line
g2d.setColor(Color.black);
g2d.setStroke(new BasicStroke(s(6)));
g2d.draw(new Line2D.Double(s(50), s(0), s(50),s(100)));
g2d.setStroke(new BasicStroke(s(1)));
//the oval
GradientPaint gradient = new GradientPaint (s(50), s(50), Color.cyan, s(50), s(100), Color.white); // true means to repeat pattern
g2d.setPaint( gradient);
g2d.fill(new RoundRectangle2D.Double(s(5),s(50),s(89),s(50),s(60),s(100)));
//the oval outline
g2d.setColor(Color.black);
g2d.drawRoundRect(s(5),s(50),s(89),s(50),s(60),s(100));
//the text of the component
G.setFont(gFont);
G.drawString("Terminate" ,s(22),s(78));
}//===========================================================================
}//=============================================================================
Thanks
Andrew.
Message was edited by:
scottie_uk
and here is the NPE to go with the abover ternimator Graphic component:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at sun.java2d.loops.DrawGlyphList.DrawGlyphList(Native Method)
at sun.java2d.pipe.SolidTextRenderer.drawGlyphList(SolidTextRenderer.java:36)
at sun.java2d.pipe.GlyphListPipe.drawString(GlyphListPipe.java:53)
at sun.java2d.SunGraphics2D.drawString(SunGraphics2D.java:2642)
at GPTool.TerminatorGraphic.paint(TerminatorGraphic.java:62)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JViewport.paint(JViewport.java:728)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JComponent.paintChildren(JComponent.java:842)
at javax.swing.JComponent.paint(JComponent.java:1014)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4963)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4916)
at javax.swing.JComponent._paintImmediately(JComponent.java:4859)
at javax.swing.JComponent.paintImmediately(JComponent.java:4666)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:451)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:114)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:158)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Hmmm. If these are Windows machines, try passing the following to the JVM on startup:-Dsun.java2d.noddraw=falseThis may be a video driver issue. Do the machines on which the NPE occurs have the same video card vendor? ATI cards are notorious for weird behavior with Java.
No I dont think it is a video driver issue. All the computers it has been tested on a vastly different with respect to graphics cards.
However, If I deploy the project as a Jar file the problem no longer presists.
Could this be a problem with the Oracle JDK (using Oricle JDeveloper). This development uses its own JDK. When running the Jar file the system uses the Sun JDK.
However, both JDK's are v1.5.
Andrew.
> No I dont think it is a video driver issue. All the
> computers it has been tested on a vastly different
> with respect to graphics cards.
>
> However, If I deploy the project as a Jar file the
> problem no longer presists.
>
> Could this be a problem with the Oracle JDK (using
> Oricle JDeveloper). This development uses its own
> JDK. When running the Jar file the system uses the
> Sun JDK.
>
> However, both JDK's are v1.5.
I believe JDeveloper uses the Sun JDK. Depending on how you acquire JDeveloper, the JDK may or may not be bundled with a JDK, but the JDK itself is Sun's. JDeveloper does have a custom VM available, but I suspect that isn't the source of the problem.
Search your file system for rogue copies of the class files which are giving you the exceptions. It is possible that you have extra copies of older versions of these classes lying around on the classpath, and these old copies are being detected by the VM before the latest and greatest version.A symptom of this problem is line numbers in the stack trace not corresponding to the correct method call in the source file.
Creating a JAR file and running it will bypass the rogue copies of the classes and the strange behavior associated with them.
Hi,I'm getting exactly the same kind of exceptions in two different applications. Since I use Oracle JDeveloper 10g, perhaps the problem is in the ojvm? I'm deploying the projects to Sun JRE, and then the exceptions never occur (I think...)Ulf
Ulfena at 2007-7-14 20:35:07 >

Ok, I've got exactly the same problem.
I was so glad to find that someone else is complaining about this problem. I've been searching for more than five days now until I bumped into this forum.
Ok, it seems its a JDeveloper issue. Since I'm having the same issue under JDeveloper 10g.
I'll try it on Suns JDK 6 and reply back.
I'll try it on Suns JDK 6 and reply back
This is very interesting. Please do report back!
I am having a similar problem running JDeveloper, XP, Java?Platform 1.5.0_06, and it is really driving me nuts. I have tried about everything I can think about this past weeks, changing fonts, changing how I draw etc, making sure every dialog has a proper parent. Everything even remotely (possibly) connected to this problem of these sporadic crashes has been changed, tested but the crashes keep coming. (Sigh)
The thing that is common to the original description above is in particular:
"What I have is a JPanel (workspace panel), within this is contained other JPanels (component panels). These component panels contain various symbols and text drawn via JavaGraphics2D."
and
"Sometimes this happens when a another component such as a JDialog obscures part of the workspace panel. "
However, the problem seem to be able to occur also under other circumstances - but I do recognize the above as rather typical for the errors.
I have also got "Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException" as shown above.
But the most common error I get is the following - exemplified here with an example:
(And note the setVisible() call)
Exception occurred during event dispatching:
java.lang.InternalError: Win32OSSD_Lock cannot nest locks
at sun.java2d.loops.DrawGlyphList.DrawGlyphList(Native Method)
at sun.java2d.pipe.SolidTextRenderer.drawGlyphList(SolidTextRenderer.java:36)
at sun.java2d.pipe.GlyphListPipe.drawString(GlyphListPipe.java:53)
at sun.java2d.SunGraphics2D.drawString(SunGraphics2D.java:2642)
at com.sun.java.swing.SwingUtilities2.drawString(SwingUtilities2.java:421)
at com.sun.java.swing.SwingUtilities2.drawStringUnderlineCharAt(SwingUtilities2.java:439)
at javax.swing.plaf.metal.MetalButtonUI.paintText(MetalButtonUI.java:179)
at javax.swing.plaf.basic.BasicButtonUI.paintText(BasicButtonUI.java:312)
at javax.swing.plaf.basic.BasicButtonUI.paint(BasicButtonUI.java:218)
at javax.swing.plaf.metal.MetalButtonUI.update(MetalButtonUI.java:114)
at javax.swing.JComponent.paintComponent(JComponent.java:742)
at javax.swing.JComponent.paint(JComponent.java:1005)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4963)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4916)
at javax.swing.JComponent._paintImmediately(JComponent.java:4859)
at javax.swing.JComponent.paintImmediately(JComponent.java:4666)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:451)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:114)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:154)
at java.awt.Dialog$1.run(Dialog.java:513)
at java.awt.Dialog.show(Dialog.java:536)
at java.awt.Component.show(Component.java:1300)
at java.awt.Component.setVisible(Component.java:1253)
at mm.main.MusicalMediatorDialog.setVisible(MusicalMediatorDialog.java:178)
at mm.utilities.MidiUtilities.selectAnInstrumentFor(MidiUtilities.java:514)
at mm.editors.editing.shapes.InstrumentSelectionEditingShape.selectAnInstrument(InstrumentSelectionEditingShape.java:201)
at mm.editors.editing.shapes.InstrumentSelectionEditingShape.handleMousePressOrReleaseEvent(InstrumentSelectionEditingShape.java:257)
at mm.editors.editing.shapes.DataEditingShape.mousePressOrReleaseEventPassedOnEvent(DataEditingShape.java:179)
at mm.editors.editing.InsideMidiTrackDataEditing.mousePressOrReleaseEvent(InsideMidiTrackDataEditing.java:173)
at mm.main.eventsets.MusicalMouseAndKeyInputSource.fireMousePressedOrReleasedEvent(MusicalMouseAndKeyInputSource.java:53)
at mm.main.eventsets.util.ShapePanelMouseAndKeyInputSource.mouseReleased(ShapePanelMouseAndKeyInputSource.java:190)
at java.awt.Component.processMouseEvent(Component.java:5488)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
at java.awt.Component.processEvent(Component.java:5253)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1774)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:158)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
I suspect that this is not an issue with JDev so much as with the JDK used to run your app. In JDeveloper 10.1.3, we ship the JDK 5 update 6 (1.5.0_06). You might want to try downloading a more recent JDK 5 (currently 1.5.0_11) or even Java SE 6. To configure your project in JDev to use the newly downloaded JDK, go to Project Properties, and go to the Libraries and Classpath page. From there, click on Change next to the Java SE version field and provide the details for your downloaded JDK.
-- Brian
Oracle JDeveloper
Product Management Team
Even now nine months on after my initial post I still get this problem.
My application as been deployed as a Jar file and working for over six months and has not once given me the same problem.
I think this must be an oricle OJVM thing. I may try developing my project in another enviroment soon because it really bites. I can't test anything reliably without first deploying it.
A.
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at sun.font.FileFont.getGlyphImage(Native Method)
at sun.font.FileFontStrike.getSlot0GlyphImagePtrs(FileFontStrike.java:388)
at sun.font.CompositeStrike.getGlyphImagePtrs(CompositeStrike.java:97)
at sun.font.GlyphList.mapChars(GlyphList.java:211)
at sun.font.GlyphList.setFromString(GlyphList.java:186)
at sun.java2d.pipe.GlyphListPipe.drawString(GlyphListPipe.java:52)
at sun.java2d.SunGraphics2D.drawString(SunGraphics2D.java:2642)
at FlowchartView.FlowchartGraphics.IfGraphic.paint(IfGraphic.java:237)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4963)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4916)
at javax.swing.JComponent._paintImmediately(JComponent.java:4859)
at javax.swing.JComponent.paintImmediately(JComponent.java:4666)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:451)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:114)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:158)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Message was edited by:
scottie_uk
