• Post Reply Bookmark Topic Watch Topic
  • New Topic

'invalid' in JPanel  RSS feed

 
Paul Keohan
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get a content pane which is always a JPanel. Sometimes, this content pane doesn't give me the 16 components I am expecting to see on it.
If I println the content pane object this is what I get when it works :
javax.swing.JPanel[numm.contentPane,0,0,384x249,layout=java.awt.GridLayout . . .
When it doesn't work, this is what the object looks like :
javax.swing.JPanel[null.contentPane,0,0,384,249,invalid,layout=java.awt.GridLayout . . . .
Everything is exactly the same except for the "invalid" in the second object. What does this "invalid" mean and while I'm on the question, where can I look up what all the values mean? I used to think they were the fields but they don't match up nicely with the javadoc fields.
Thanks.
Paul
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the toString() for Container:

You would need to trace the paramString() to find out what it is for the JPanel.
 
Paul Keohan
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a great piece of information to know. Thanks!
I've looked into why it says 'invalid' and it's apparently because the component needs to be laid out. This is according to the documentation in the Component class. I get this content pane again and again and 95% of the time it's okay. Is there any particular reason why sometimes it needs to be laid out? I'm thinking it's a timing kind of issue. I get the data from a bunch of components which I have no control over.
Paul
 
Bill Liteplo
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are many reasons why components are invalidated. You would have to provide more code to get a better idea.
You can do the good ol'

if you have a good place in the code for it.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!