• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to embed frame of another file to panel

 
L Willie
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
following class would display digital clock


i want to embed above frame to following panel,generateTimeStampPanel


Sincerely

willie
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't. You would have to change DigClock so that it extends a container than can be placed inside another container, like JPanel for example. An Applet cannot be used that way.
 
Rob Spoor
Sheriff
Posts: 20817
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can most definitely add an (J)Applet to a frame - I just tried it. It makes sense since Applet (indirectly) extends Container and therefore also Component. I can remember though that it didn't work in older versions of Java.

However, Applet and JApplet are heavyweight components, and may cause problems when combining with lightweight components.


I do agree that DigClock should extend JPanel instead, and then be added to a new Applet when needed.
 
L Willie
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank Rob and Gregg reply
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rob Prime:
I do agree that DigClock should extend JPanel instead, and then be added to a new Applet when needed.


Sorry to be a nitpicker, but that should read "and then be added to a new JApplet when needed." Thanks.
 
Rob Spoor
Sheriff
Posts: 20817
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are right of course. I prefer JApplet over Applet myself too.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!