• Post Reply Bookmark Topic Watch Topic
  • New Topic

What causes a frame to just not show up?  RSS feed

 
Tom McC
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, this is my first time posting here, second time here =)

I have this Java project I've been working on that passes around an "engine" class to most of the GUI components. The engine class just provides me a way to get data to all the components and still keep it separate from the GUI. This has been working fine; I usually have constructors that allow me to set the local engine object to the one passed to it, so all the GUI components are working with the same engine object.

However, with the last two classes I wrote, I was disappointed to find out that trying to call any part of the engine would cause the JFrame of the program not to show up. (I'm using netBeans 4.1, and it'll say "run:" but then "BUILD SUCCESSFUL" right afterwards, and the JFrame will load into memory but never appear, giving me no error message whatsoever). I finally traced it down to any statements involving engine methods that would cause this odd problem.

Are there any problems that typically cause this strange behavior? I checked to make sure that every local engine reference was made AFTER receiving the correct reference from the constructor (so I wasn't trying to use an uninitialized engine).

I also received this problem when trying to create a panel with a CardLayout, although I have other CardLayouts in the program and have never had problems until now... Any insight into these or why these problems are caused would be helpful.

Thanks!
 
Tom McC
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suppose I should have checked more carefully before I posted. The problem ended up being that I did not set the local engine instance variable before spawning the new class with the non-initialized variable. (Even though I thought I checked for that, go figure.) It's like doing this:



I think that the most frustrating part of it was that I got no compile/runtime error whatsoever. That way, I had no idea even where to start looking for the problem. Java should really not let a JFrame do this without triggering a runtime error or something.

Tom
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Tom McC:
Java should really not let a JFrame do this without triggering a runtime error or something.


Do what?

I see the problem you found, but I'm curious to know what you think the language could do to help here. I'm assuming the InnerClass is the thing that would instantiate the JFrame, but you're passing a null to the constructor, so that's not happening. Why isn't it? If the InnerClass does anything with the constructor argument other than copy it, it should get a NullPointerException, which means either 1) it doesn't actually do anything, or 2) it does something like



and is therefore ignoring the NullPointerException that would have explained the problem. Which is it?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!