JFrame Issue

Reply

Join Date: Jul 2005
Posts: 45
Reputation: Sp!ke is an unknown quantity at this point 
Solved Threads: 0
Sp!ke's Avatar
Sp!ke Sp!ke is offline Offline
Light Poster

JFrame Issue

 
0
  #1
Jun 1st, 2007
This is a really strange bug...

I'm doing a 'game' of sorts for Computer Science, and it works wonderfully. We have a main method that initializes things and starts the game loop. The game itself works when GUI.java is executed.

Every method call in the main method is static.

Now, the odd thing is that when that exact same code (copy and paste) is run from a different class, and either executed statically, or even when creating a new object and using that as a reference, both JFrames show up as necessary, but they are EMPTY. Big gaping transparent holes of nothing.

Can someone explain this phoenomenon?

FYI: Here's the main method I'm referring to:
  1. // In class GUI:
  2.  
  3. public static void main(String[] args) {
  4. init(); //static
  5. Console.run(frame, 808, 635); //Console class is static, frame is static
  6. panel.paintLevel(); // static
  7. panel.paintLevel(); // static
  8. frame.run(); // static
  9. }
And when called externally, either this:
  1. // In External Class:
  2.  
  3. GUI.init();
  4. Console.run(GUI.frame, 808, 635);
  5. GUI.panel.paintLevel();
  6. GUI.panel.paintLevel();
  7. GUI.frame.run();
or this
  1. // In External Class:
  2.  
  3. GUI gui = new GUI();
  4. gui.init();
  5. Console.run(gui.frame, 808, 635);
  6. gui.panel.paintLevel();
  7. gui.panel.paintLevel();
  8. gui.frame.run();
does the transparent frame effect.

Let me know if you need more information.
Last edited by Sp!ke; Jun 1st, 2007 at 1:49 am.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 4,439
Reputation: Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of Ezzaral has much to be proud of 
Solved Threads: 510
Moderator
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Industrious Poster

Re: JFrame Issue

 
0
  #2
Jun 1st, 2007
I don't think we can provide any insight without seeing the panel and frame classes.

On a side note, your may want to reconsider your design in making everything static and trying to manage the interactions by calling static methods on the objects. The main method should really only be responsible for creating whatever minimal number of objects are needed to set up the environment of your program. All other operations should be performed by those objects themselves.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 41
Reputation: hussulinux is an unknown quantity at this point 
Solved Threads: 2
hussulinux hussulinux is offline Offline
Light Poster

Re: JFrame Issue

 
0
  #3
Jun 7th, 2007
Try calling the main function of GUI from the external class's method...
This is what actually JVM does...

Is there any package involved?

Also post more code, we'd like to test it on our machines too.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC