Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Show JPanel in another class HELP !!!!

 
Rich Charlton
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have two classes, one with a main method that displays a main frame. and another which makes a JPanel which i would like to display on the main frame in the other class. I have it working and compiling but not really showing on the main frame like i want it. It shows in the main frame as a very small square grey box.

Main Frame Program called testpanel:


Second Class called addpanel.


I need to be able to see the JPanel made in the second class in the main frame made in the first class, if that makes any sense.

Can anyone help me please !

Thanks
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in addpanel(), you're creating a number of components and adding them to
typeinfo, but it is not typeinfo being added to testpanel, it is an instance
of addpanel. You need to add typeinfo to addpanel

at the end of the addpanel constructor

 
Rich Charlton
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Yeh this has worked.

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic