AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Exception In thread "SyntheticImageGenerator" URGENT HELP

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Language Programming
View previous topic :: View next topic  
Author Message
Mehmet Metan
Guest





PostPosted: Thu Mar 16, 2006 9:12 am    Post subject: Exception In thread "SyntheticImageGenerator" URGENT HELP Reply with quote



hello to all.

Exception In thread "SyntheticImageGenerator"
java.lang.OutOfMemoryError: Java heap space


I ve two classes. and I am getting the above error.

Neccessary code is below:

public class MainEngineeringToolFrame extends JFrame implements
ActionListener.
{
//Some Code...
public MainEngineeringToolFrame
{
super("HELP PLS");
System.out.println("**super passed");
setBounds(120,300,1024,428);
setResizable(false);
System.out.println("**next code: Set Visible true");
setVisible(true);
}

//Some Code...

public static void main(String[] args)
{
System.out.println("***Main function loaded.");
MainEngineeringToolFrame frame = new MainEngineeringToolFrame();
System.out.println("***Object created.");
// frame.setTitle
// frame.setResizable
// getContentPane
// add(....
setVisible(true);
}

}



This is my fiirst class.
I created another class for the panel. where painting will occur in it.
necessary code is below:

public class DrawingPanel extends JPanel implements MouseListener,
MouseMotionListener
{
MainEngineeringToolFrame obj = new MainEngineeringToolFrame();

public DrawingPanel()
{
super();
addMouseListener(this);
addMouseMotionListener(this);
setLayout(null);
}

//paint func.
//implemented methods.
}




At the System Line it only prints:

***Main function loaded.


What means it can't create an object from itself in the main class.
than program tries to build itself some time.
And gives an error message like:
I thought increasing the heap space in ecliopse from VM arguments in
run properties window in arguments tag. where under Java Application
(Im thinking u r familliar with eclipse.)

Why does it happpen? I thought this kind of exception may occur in an
infiniteloop where infinite objects are created. Well I dont even have
a loop or Im not creating infinite number of objects..

Any helps appriciated
best regards
metan
Back to top
Chris Uppal
Guest





PostPosted: Thu Mar 16, 2006 11:12 am    Post subject: Re: Exception In thread "SyntheticImageGenerator" URGENT HEL Reply with quote



Mehmet Metan wrote:

Quote:
public class MainEngineeringToolFrame extends JFrame implements
ActionListener.
{
[...]
}


public class DrawingPanel extends JPanel implements MouseListener,
MouseMotionListener
{
MainEngineeringToolFrame obj = new MainEngineeringToolFrame();

I doubt if you are showing us the code that we need to see.

One thing that ocurs to me, though, is that if your code adds a new
DrawingPanel to a MainEngineeringToolFrame then you'll have problems. Creating
the DrawingPanel will create a new MainEngineeringToolFrame, which will in turn
will create a new DrawingPanel, which will....

-- chris
Back to top
Mehmet Metan
Guest





PostPosted: Thu Mar 16, 2006 12:12 pm    Post subject: Re: Exception In thread "SyntheticImageGenerator" URGENT HEL Reply with quote



I ve tried commenting that line but all other obj.smthing related code
is having a null pointer exceptiion. i ve initialized the obj object.
Why i am getting a null pointer exception? Two classes are in the same
package.

regards.
Back to top
Mehmet Metan
Guest





PostPosted: Thu Mar 16, 2006 12:12 pm    Post subject: Re: Exception In thread "SyntheticImageGenerator" URGENT HEL Reply with quote

Ok thats right. I initialize the DrawingPanel in the
MainEngineeringToolFrame like:

private DrawingPanel mDrawingPnl = new DrawingPanel();

other operations for mDrawingPnl in the MainEngineeringToolFrame class
are like below:

public void initComponents() //called in constructor
{
// some code.
mDrawingPnl.setBounds(50,50,200,400);
mDrawingPnl.setVisible(true); // I dont know =]
}

public Component buildPanel() //function is for adding components to
the defined layout with coordinates.
//I ve used JGoodies forms for layout manage. dont need to focus on
that
{
//some code
PanelBuilder panel = new PanelBuilder(layout);
//a lot of builder.add(....
builder.add(mDrawingPnl, cc.xy(5,1)); //coordinates.

return builder.getPanel();
}

main
{
//some code
frame.add(frame.buildPanel());
frame.setVisible(true);
}

And I replaced the DrawingPanel class like this

public class DrawingPanel extends JPanel implements MouseListener,
MouseMotionListener
{
public MainEngineeringToolFrame obj = new
MainEngineeringToolFrame();

but now I m getting a lot of nullPointer exceptions refering to the
variables derived from obj.
Such as in paint function

public void paint(Graphics g)
{
super.paint(g);
g.setColor(obj.getMCurrentColor()); //used the getter method of Color
currentColor variable
}

4 exceptions occured in this line
g.setColor(obj.getMCurrentColor());

saying:
Exception in thread "AWT-EventQueue-0' java.lang.NullPointerException


4 exceptions occured right after each other in one time.


Your helps are appriciated. Thanx again.
and help again pls :)

best regards
metan
Back to top
Mehmet Metan
Guest





PostPosted: Thu Mar 16, 2006 4:12 pm    Post subject: Re: Exception In thread "SyntheticImageGenerator" URGENT HEL Reply with quote

well the problem is because of the MainEngineeringToolFrame obj = new
MainEngineeringToolFrame(); object after debugging. but i am still not
able to understand why..

well in this decleration it is expected that a null pointer exception
will occur

public MainEngineeringToolFrame obj;


but the program window is visible and by buttons and stuff are
available. However any action is taken it is giving a null pointer
exception to the

obj.something

declerations. Ok I understand that. It is normal
but when i initialize the object with its constructor like

public MainEngineeringToolFrame obj = new MainEngineeringToolFrame();


it is giving the

Exception In thread "SyntheticImageGenerator"
java.lang.OutOfMemoryError: Java heap space

error and terminates the program without initialization. What would i
have to do?

In addition I think the declarations and initializations of
DrawingPanel object in the MainEngineeringToolFrame is correct.. if not
may be the problem can be solved there..

necessary code is below:

public class MainEngineeringToolFrame extends JFrame implements
ActionListener.
{
//Some Code...
private DrawingPanel mDrawingPnl = new DrawingPanel();

public MainEngineeringToolFrame()
{
super("HELP PLS");
setBounds(120,300,1024,428);
setResizable(false);
initComponents();
setVisible(true);

}
public void initComponents() //called in constructor
{
// some code.
mDrawingPnl.setBounds(50,50,200,400);
mDrawingPnl.setVisible(true); // I dont know =]

}

//function is for adding components to the defined layout with
coordinates.
//I ve used JGoodies forms for layout manage. dont need to focus on
public Component buildPanel()
{
//some code
PanelBuilder panel = new PanelBuilder(layout);
//a lot of builder.add(....
builder.add(mDrawingPnl, cc.xy(5,1)); //coordinates.

return builder.getPanel();

}
//Some Code...

public static void main(String[] args)
{
System.out.println("***Main function loaded.");
MainEngineeringToolFrame frame = new MainEngineeringToolFrame();
System.out.println("***Object created.");
// frame.setTitle
// frame.setResizable
// getContentPane
// add(....
frame.add(frame.buildPanel());
setVisible(true);
}

}



Second class

public class DrawingPanel extends JPanel implements MouseListener,
MouseMotionListener
{
MainEngineeringToolFrame obj = new MainEngineeringToolFrame();

public DrawingPanel()
{
super();
addMouseListener(this);
addMouseMotionListener(this);
setLayout(null);
}

public void paint(Graphics g)
{
super.paint(g);
g.setColor(obj.getMCurrentColor()); //used the getter method of
Color currentColor variable
//Exception will occur.

}
//implemented methods.

}



Any suggestions are very appriciated.
Thanx
regards.
Back to top
Rhino
Guest





PostPosted: Thu Mar 16, 2006 4:12 pm    Post subject: Re: Exception In thread "SyntheticImageGenerator" URGENT HEL Reply with quote

"Mehmet Metan" <phreaker85 (AT) gmail (DOT) com> wrote in message
news:1142498745.312139.191680 (AT) i39g2000cwa (DOT) googlegroups.com...
Quote:
hello to all.

Exception In thread "SyntheticImageGenerator"
java.lang.OutOfMemoryError: Java heap space


I ve two classes. and I am getting the above error.

Neccessary code is below:

public class MainEngineeringToolFrame extends JFrame implements
ActionListener.
{
//Some Code...
public MainEngineeringToolFrame
{
super("HELP PLS");
System.out.println("**super passed");
setBounds(120,300,1024,428);
setResizable(false);
System.out.println("**next code: Set Visible true");
setVisible(true);
}

//Some Code...

public static void main(String[] args)
{
System.out.println("***Main function loaded.");
MainEngineeringToolFrame frame = new MainEngineeringToolFrame();
System.out.println("***Object created.");
// frame.setTitle
// frame.setResizable
// getContentPane
// add(....
setVisible(true);
}

}



This is my fiirst class.
I created another class for the panel. where painting will occur in it.
necessary code is below:

public class DrawingPanel extends JPanel implements MouseListener,
MouseMotionListener
{
MainEngineeringToolFrame obj = new MainEngineeringToolFrame();

public DrawingPanel()
{
super();
addMouseListener(this);
addMouseMotionListener(this);
setLayout(null);
}

//paint func.
//implemented methods.
}




At the System Line it only prints:

***Main function loaded.


What means it can't create an object from itself in the main class.
than program tries to build itself some time.
And gives an error message like:
I thought increasing the heap space in ecliopse from VM arguments in
run properties window in arguments tag. where under Java Application
(Im thinking u r familliar with eclipse.)

If you are using Eclipse, then you will probably get the best understanding

of the problem by running the debugger and stepping through the program one
line at a time. If you do this carefully, you will soon see where the
program starts to misbehave and you will probably be able to figure out why.
Maybe some object that you thought was created correctly wasn't created
after all and the problems all stem from that.

Try this approach and if you see some behaviour that you don't understand,
ask here and someone may be able to explain why the bad behaviour is taking
place.


Quote:
Why does it happpen? I thought this kind of exception may occur in an
infiniteloop where infinite objects are created. Well I dont even have
a loop or Im not creating infinite number of objects..

Any helps appriciated
best regards
metan

Rhino
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Language Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.