• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What causes a frame to just not show up?

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Evil is afoot. But this tiny ad is just an ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic